Apport uses 'any' even in python2.4, causing NameError

Bug #104864 reported by Christopher Armstrong
22
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Fix Released
Medium
Martin Pitt
Feisty
Fix Released
Medium
Martin Pitt
Gutsy
Fix Released
Medium
Martin Pitt

Bug Description

Binary package hint: apport

Pretty straightforward: when a python2.4 application of mine crashed, this traceback occured, showing that apport is using python2.5-only features even in python2.4.

Error in sys.excepthook:
Traceback (most recent call last):
  File "/var/lib/python-support/python2.4/apport/python_hook.py", line 54, in apport_excepthook
    pr.add_proc_info()
  File "/var/lib/python-support/python2.4/apport/report.py", line 334, in add_proc_info
    self._check_interpreted()
  File "/var/lib/python-support/python2.4/apport/report.py", line 244, in _check_interpreted
    if not any([fnmatch.fnmatch(exebasename, i) for i in interpreters]):
NameError: global name 'any' is not defined

Martin Pitt (pitti)
Changed in apport:
assignee: nobody → pitti
importance: Undecided → Medium
status: Unconfirmed → In Progress
Revision history for this message
Barry Warsaw (barry) wrote :

Simple workaround would be something like this at the top of the file:

try:
    any
except NameError:
     # Taken from Python 2.5 built-in documentation
     def any(iterable):
         for element in iterable:
             if element:
                 return True
         return False

Revision history for this message
Martin Pitt (pitti) wrote :

Fixed in bzr head, will upload early in gutsy.

Changed in apport:
status: In Progress → Fix Committed
Revision history for this message
Matthew Carpenter (matt-eisgr) wrote :

Not sure what this means. Does this mean that it will only be fixed in Gutsy? I'm not familiar with "bzr head", but will this be fixed for Feisty's release?

Thanks.

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 104864] Re: Apport uses 'any' even in python2.4, causing NameError

Hi Matthew,

Matthew Carpenter [2007-04-16 18:03 -0000]:
> Not sure what this means. Does this mean that it will only be fixed in
> Gutsy? I'm not familiar with "bzr head", but will this be fixed for
> Feisty's release?

Since I do not see that this is a critical bug for Feisty, it will
only be fixed in Gutsy, yes.

Revision history for this message
Matthew Carpenter (matt-eisgr) wrote :

On Tuesday 17 April 2007, Martin Pitt wrote:
> Hi Matthew,
>
> Matthew Carpenter [2007-04-16 18:03 -0000]:
> > Not sure what this means. Does this mean that it will only be fixed in
> > Gutsy? I'm not familiar with "bzr head", but will this be fixed for
> > Feisty's release?
>
> Since I do not see that this is a critical bug for Feisty, it will
> only be fixed in Gutsy, yes.

Forgive me if I don't understand the logic, but will it at least be backported
to Feisty after the upcoming release? Not that it would seem a devastating
bug, but the potential impact surface is huge.
Any existing 2.4 application that uses sys.excepthook() to log and continue
execution will now fail. That means that unlucky folk who upgrade from Edgy
to Feisty with such applications (home-grown, third-party, or
ubuntu-provided) will take a step backwards in usability.

I don't know what is involved in the fix for this, and I understand that it is
close to release-time and that making changes right now is restricted to
earth-shattering bugs. However, skipping a bug with such wide-reaching
implications for an entire distro-cycle would make Ubuntu look rinky-dink.

Not that I'm unappreciative. I thank you and everyone for your time work hard
work. This is just my way of providing feedback to help improve the best
distro available.

Revision history for this message
Martin Pitt (pitti) wrote :

Matthew: Ah, I see what you mean. Right, good candidate for -updates then, added a task.

Revision history for this message
Matthew Carpenter (matt-eisgr) wrote :

Thank you, Martin. And I will continue to sing the praises of Ubuntu with
pride :)

Revision history for this message
Martin Pitt (pitti) wrote :

Test for the SRU reviewers: Edit /usr/bin/bzr, change the #! line to /usr/bin/python2.4, and append an 'assert False' after it.

With current Feisty:

$ bzr
Traceback (most recent call last):
  File "/usr/bin/bzr", line 24, in ?
    assert False
AssertionError
Error in sys.excepthook:
Traceback (most recent call last):
  File "/var/lib/python-support/python2.4/apport_python_hook.py", line 54, in apport_excepthook
    pr.add_proc_info()
  File "/var/lib/python-support/python2.4/apport/report.py", line 334, in add_proc_info
    self._check_interpreted()
  File "/var/lib/python-support/python2.4/apport/report.py", line 244, in _check_interpreted
    if not any([fnmatch.fnmatch(exebasename, i) for i in interpreters]):
NameError: global name 'any' is not defined

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/bzr", line 24, in ?
    assert False
AssertionError

With SRU package:

$ bzr
Traceback (most recent call last):
  File "/usr/bin/bzr", line 24, in ?
    assert False
AssertionError

Revision history for this message
Martin Pitt (pitti) wrote :

Oh, for the test above you must install python-ctypes, otherwise the effect will be shadowed by bug 107662.

Revision history for this message
Martin Pitt (pitti) wrote :

Uploaded to feisty-proposed:

 apport (0.76.1~prop1) feisty-proposed; urgency=low
 .
   Fix breakage with all applications that use Python 2.4:
 .
   * apport/report.py: Replace any() call with a list comprehension to work
     with Python < 2.5. (LP: #104864)
   * apport/report.py: Move the ctypes import to the one place where we
     actually need it, and do not entirely fail if they do not exist (such as
     in Python 2.4). It is only required for non-default Feisty kernels anyway.
     (LP: #107662)

Acceptance is pending the proper gutsy changes for Soyuz, currently the publisher is broken.

Changed in apport:
status: Fix Committed → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

Accepted into feisty-proposed.

Changed in apport:
status: In Progress → Fix Committed
Revision history for this message
Michael Vogt (mvo) wrote :

I verified this using the suggested test in comment 8 (thanks for providing those instructions!) and it works now as expected.

Revision history for this message
Martin Pitt (pitti) wrote :

 apport (0.77) gutsy; urgency=low
 .
   * apport/report.py: Replace any() call with a list comprehension to work
     with Python < 2.5. (LP: #104864)
   * apport/report.py: Move the ctypes import to the one place where we
     actually need it, and do not entirely fail if they do not exist (such as
     in Python 2.4). It is only required for non-default Feisty kernels anyway.
     (LP: #107662)
   * apport/chroot.py: Fix test suite to work with Python 2.4's tarfile module
     output format.
   * debian/local/setup-apport-retracer: Generalized some feisty specific
     bits, set default release to gutsy.

Changed in apport:
status: Fix Committed → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

Accepted into feisty-updates.

Changed in apport:
status: Fix Committed → 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.