apport crashes if sys.argv is empty or non-existent

Bug #207555 reported by JLKenyon
2
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
In Progress
Undecided
Martin Pitt

Bug Description

Binary package hint: python-apport

When embedding python (as in with Boost Python) one sometimes will have an empty or non-existent sys.argv variable. If the program crashes, while the python instance is active, apport will run, but will crash with the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: __import__ not found
Error in sys.excepthook:
Traceback (most recent call last):
  File "/var/lib/python-support/python2.5/apport_python_hook.py", line 49, in apport_excepthook
    binary = os.path.realpath(os.path.join(os.getcwdu(), sys.argv[0]))
AttributeError: 'module' object has no attribute 'argv'

This is because sys.argv doesn't exist for some embedded instances of python (this is a really rare instance).

A simple work-around (aka hack) is to edit
/var/lib/python-support/python2.5/apport_python_hook.py

And modify it look like:
import os
import sys

# new lines
try:
    sys.argv
except:
    sys.argv = ['no_main']

Martin Pitt (pitti)
Changed in apport:
assignee: nobody → pitti
status: New → In Progress
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.