[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#523801: Returns invalid Version objects on packages without candidate versions



Package: python-apt
Version: 0.7.10.1
Severity: critical

Hello,

I'm setting the severity to 'critical' because it causes several other
packages to break, including goplay, ept-cache and basically anything
that uses or recommends apt-xapian-index (see #521346, #523737 and
#523747).

I'm attaching a short test case.  When run on a system which contains a
package in status 'config-files' and with no information in the apt
database, package.candidate gives a version object that throws on every
single method.  

I assume that this is a bug: in a normal API, I would expect to get None
when asking for a candidate version: in fact, there is None.

 # dpkg -s bist
 Package: bist
 Status: deinstall ok config-files
 Priority: optional
 Section: science
 Installed-Size: 2664
 Maintainer: David Paleino <d.paleino@gmail.com>
 [...]

 $ ./testcase.py
 Looking for the situation that annoys Enrico...
 Enrico is annoyed by the behaviour of python-apt on bist
 Traceback (most recent call last):
   File "./testcase2.py", line 16, in <module>
     dummy = ver.raw_description
   File "/usr/lib/python2.5/site-packages/apt/package.py", line 257, in raw_description
     return self._records.LongDesc
   File "/usr/lib/python2.5/site-packages/apt/package.py", line 214, in _records
     if self.package._pcache._records.Lookup(self._cand.FileList[0]):
 AttributeError: 'NoneType' object has no attribute 'FileList'


I would rather not have to work around this by wrapping every read of a
property of Version in try/except, and I wish you can fix this soon,
because I'm getting several nasty bug reports.

If you cannot/won't fix it soon, at least let me know.  Please don't
leave me hanging with a nonfunctional package and no answer for a month
like you did with #513315.


Best of all,

Enrico

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-apt depends on:
ii  apt [libapt-pkg-libc6.7-6-4.6 0.7.20.2   Advanced front-end for dpkg
ii  apt-utils [libapt-inst-libc6. 0.7.20.2   APT utility programs
ii  libc6                         2.9-7      GNU C Library: Shared libraries
ii  libgcc1                       1:4.3.3-5  GCC support library
ii  libjs-jquery                  1.3.2-2    JavaScript library for dynamic web
ii  libstdc++6                    4.3.3-5    The GNU Standard C++ Library v3
ii  lsb-release                   3.2-22     Linux Standard Base version report
ii  python                        2.5.4-2    An interactive high-level object-o
ii  python-central                0.6.11     register and build utility for Pyt

Versions of packages python-apt recommends:
pn  iso-codes                     <none>     (no description available)

Versions of packages python-apt suggests:
pn  python-apt-dbg                <none>     (no description available)
pn  python-gtk2                   <none>     (no description available)
pn  python-vte                    <none>     (no description available)

-- no debconf information
#!/usr/bin/python
# Try to reproduce the python-apt problem behind #523737, #523747 and #521346

import apt, sys

print "Looking for the situation that annoys Enrico..."
cache = apt.Cache(memonly=True)
for pkg in cache:
    ver = pkg.candidate
    if ver is None:
        print >>sys.stderr, name, "has no candidate version"
        sys.exit(0)

    # python-apt should not raise an exception at this point
    try:
        dummy = ver.raw_description
    except:
        print "Enrico is annoyed by the behaviour of python-apt on", pkg.name
        raise

print "You don't have any packages that cause python-apt to annoy Enrico"

Reply to: