Bug#760549: python-apt: apt_pkg.init_config() should apt_pkg.config.clean()
Package: python-apt
Version: 0.9.3.9
Severity: normal
I have had symptoms very similar to http://bugs.debian.org/728274 but in
a different context.
I want to use apt_pkg directly and want to call apt_pkg.init() after
having set APT_CONFIG to point to my custom configuration. Unfortunately
my code also "import apt" (because it needs apt.progress.base.AcquireProgress)
and that import unhelpfully triggers apt_pkg.init().
Even though I'm calling that a second time, the configuration is not
cleared and while the entries I have defined are overriden, the global
entries (such as APT::Target-Release) are there to interfere with
my logic.
Thus I believe that a call to apt_pkg.init_config() should really clear
the apt_pkg.config object first. That's what I did in my code:
http://anonscm.debian.org/cgit/qa/distro-tracker.git/commit/?id=e34d8aaaca11b0706ffa9a773f65442c9c24c987
+ # Clean up the configuration we might have read during "import apt"
+ for root_key in apt_pkg.config.list():
+ apt_pkg.config.clear(root_key)
+ # Load the proper configuration
apt_pkg.init()
Furthermore it would be nice if the configuration was loaded in a lazy
way in all the apt.* modules. That would probably solve #728274.
-- System Information:
Debian Release: jessie/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.14-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-apt depends on:
ii libapt-inst1.5 1.0.7
ii libapt-pkg4.12 1.0.7
ii libc6 2.19-10
ii libgcc1 1:4.9.1-12
ii libstdc++6 4.9.1-12
ii python 2.7.8-1
ii python-apt-common 0.9.3.9
Versions of packages python-apt recommends:
ii iso-codes 3.56-1
ii lsb-release 4.1+Debian13
ii xz-utils 5.1.1alpha+20120614-2
Versions of packages python-apt suggests:
pn python-apt-dbg <none>
ii python-apt-doc 0.9.3.9
ii python-gtk2 2.24.0-4
ii python-vte 1:0.28.2-5
-- no debconf information
Reply to: