apport_python_hook.py sys.argv check broken for embedded Python interpreter

Bug #119437 reported by Graham Dumpleton
6
Affects Status Importance Assigned to Milestone
Apport
Fix Released
Undecided
Unassigned
apport (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

In apport_python_hook.py it has code:

  binary = os.path.realpath(os.path.join(os.getcwdu(), sys.argv[0]))

Ie., it assumes that sys.argv will always exist.

This will not be the case for where Python is being used embedded within a custom C application as normally it is the Python command line executable that would set up sys.argv but where Python is used in an embedded system setting up sys.argv never occurs.

That apport is assuming sys.argv doesn't exist will cause systems like mod_python and mod_wsgi to fail on startup. For example see:

  http://groups.google.com/group/mod_python/browse_thread/thread/9d6cfa563d67b5c6

This will occur because even though mod_python and mod_wsgi setup a fake sys.argv to satisfy Python modules that may try and use it, the apport code is executed as part of the Python initialisation phase when the interpreter is first being initialised and thus before mod_python and mod_wsgi can fake up sys.argv.

Thus, you should change your code to check if sys.argv exists.

Revision history for this message
Wrwrwr (wrwrwr) wrote :

I can confirm this fails with (some newer versions of) crystal space game engine.

Revision history for this message
Marco Rodrigues (gothicx) wrote :

Hi! Do you still have this problem with current version of Apport in Ubuntu Karmic ?

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

This was fixed a while ago.

Changed in apport:
status: New → Fix Released
Changed in apport (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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