apt.Cache.__iter__ breaks when multiarch is enabled

Bug #740072 reported by Colin Watson
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
Fix Released
Medium
Unassigned
Oneiric
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: python-apt

After enabling multiarch (adding a 'deb [arch=i386,amd64]' line to sources.list, setting 'APT::Architectures { "i386"; "amd64"; }' in apt.conf, setting 'foreign-architecture amd64' in dpkg.cfg, and removing and regenerating the APT cache from scratch), I get this in cron mail:

/etc/cron.daily/apt:
Traceback (most recent call last):
  File "/usr/sbin/update-apt-xapian-index", line 104, in <module>
    indexer.rebuild(opts.pkgfile)
  File "/usr/lib/pymodules/python2.7/axi/indexer.py", line 692, in rebuild
    self.buildIndex(dbdir, generator)
  File "/usr/lib/pymodules/python2.7/axi/indexer.py", line 667, in buildIndex
    for doc in documents:
  File "/usr/lib/pymodules/python2.7/axi/indexer.py", line 540, in gen_documents_apt
    for idx, pkg in enumerate(cache):
  File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 173, in __iter__
    yield self[pkgname]
  File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 158, in __getitem__
    pkg = self._weakref[key] = Package(self, self._cache[key])
KeyError: 'lib32asound2'

This is failing because lib32asound2 is in cache._cache.packages (and therefore in cache._sorted_set), but cache._cache['lib32asound2'] fails. I note:

>>> cache._cache['lib32asound2']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'lib32asound2'
>>> cache._cache['lib32asound2:amd64']
<apt_pkg.Package object: name:'lib32asound2' section: 'libs' id:4011>

It looks as though perhaps apt.Cache needs to be aware of foreign-architecture packages and look them up differently?

Tags: multiarch
Revision history for this message
Julian Andres Klode (juliank) wrote :

We don't have multi-arch support in python-apt yet.

Changed in python-apt (Ubuntu):
status: New → Confirmed
Revision history for this message
Colin Watson (cjwatson) wrote :

This also causes nvidia-common to fail to configure when multiarch is enabled.

Revision history for this message
Steve Langasek (vorlon) wrote :

This is basically critical path for widespread deployment of multiarch to end-users.

Changed in python-apt (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Julian Andres Klode (juliank) wrote :

Fixed in python-apt's debian-sid branch. This should land in natty once we fixed some
other bugs, merged it and tested it.

The relevant revisons are:
    http://bzr.debian.org/scm/loggerhead/apt/python-apt/debian-sid/revision/484
    http://bzr.debian.org/scm/loggerhead/apt/python-apt/debian-sid/revision/485
    http://bzr.debian.org/scm/loggerhead/apt/python-apt/debian-sid/revision/488

Changed in python-apt (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-apt - 0.7.100.3ubuntu1

---------------
python-apt (0.7.100.3ubuntu1) natty; urgency=low

  * merge fixes from debian-sid, most notably the fixes
    to support multiarch (thanks to Julian Andres Klode)

python-apt (0.7.100.3) unstable; urgency=low

  [ Barry Warsaw ]
  * PyFetchProgress::Pulse(): When ignoring a false return value from
    PyArg_Parse() after running the simple callback pulse(), there can be
    an exception on the stack, which must be cleared. (LP: #711225)

  [ Michael Vogt ]
  * python/arfile.cc, apt/debfile.py:
    - add support for .xz archives
  * tests/test_debfile.py:
    - add test for xz compression
  * update priority of python3-apt to match the archive

  [ Julian Andres Klode ]
  * python/cache.cc:
    - Add Package.get_fullname() and Package.architecture
  * apt/cache.py, apt/package.py:
    - Add architecture property to apt.Package (LP: #703472)
    - Change apt.Package.name to use get_fullname(pretty=True) (LP: #740072)
  * tests/test_debfile.py:
    - Disable multi-arch for the test, it fails when run via test_all.py
    - Fix mixed tab/spaces indentation in xz test
  * tests/test_apt_cache.py:
    - Package records 'Package' field now corresponds to shortname
  * debian/python3-apt-dbg.install
    - Do not try to install old-style debugging files.
  * debian/rules:
    - Support the nocheck build option and ignore test failures on hurd
      (Closes: #610448)
    - Move Python 3 debug files before installing other files (Closes: #619528)

  [ Scott Kitterman ]
   * Removed ${python:Breaks} - No longer used in dh_python2
 -- Michael Vogt <email address hidden> Mon, 04 Apr 2011 16:15:15 +0200

Changed in python-apt (Ubuntu):
status: Fix Committed → Fix Released
Michael Vogt (mvo)
Changed in python-apt (Ubuntu Oneiric):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.