apport-hackers team mailing list archive
-
apport-hackers team
-
Mailing list archive
-
Message #00038
[Merge] lp:~mdz/apport/681574-improve-python-titles into lp:apport
Matt Zimmerman has proposed merging lp:~mdz/apport/681574-improve-python-titles into lp:apport.
Requested reviews:
Apport upstream developers (apport-hackers)
Related bugs:
#681574 Standard title for Python crashes could be more specific
https://bugs.launchpad.net/bugs/681574
Improve standard titles for Python bugs.
If the crash occurs at the top level in the main program:
"foo crashed with ImportError"
If the crash occurs at the top level in a module:
"foo crashed with ImportError in /usr/share/foo/plugin.py"
Also include the exception text in the report, e.g.:
"foo crashed with ImportError: No module named nonexistent"
--
https://code.launchpad.net/~mdz/apport/681574-improve-python-titles/+merge/41900
Your team Apport upstream developers is requested to review the proposed merge of lp:~mdz/apport/681574-improve-python-titles into lp:apport.
=== modified file 'apport/report.py'
--- apport/report.py 2010-06-01 08:09:39 +0000
+++ apport/report.py 2010-11-25 20:57:00 +0000
@@ -880,22 +880,46 @@
os.path.basename(self['ExecutablePath']),
trace[0])
- trace_re = re.compile('^\s*File.* in (.+)$')
+ trace_re = re.compile('^\s*File\s*"(\S+)".* in (.+)$')
i = len(trace)-1
function = 'unknown'
while i >= 0:
m = trace_re.match(trace[i])
if m:
- function = m.group(1)
+ module_path = m.group(1)
+ function = m.group(2)
break
i -= 1
- return '%s crashed with %s in %s()' % (
- os.path.basename(self['ExecutablePath']),
- trace[-1].split(':')[0],
- function
+ path = os.path.basename(self['ExecutablePath'])
+ last_line = trace[-1]
+ exception = last_line.split(':')[0]
+ m = re.match('^%s: (.+)$' % exception, last_line)
+ if m:
+ message = m.group(1)
+ else:
+ message = None
+
+ if function == '<module>':
+ if module_path == self['ExecutablePath']:
+ context = '__main__'
+ else:
+ # Maybe use os.path.basename?
+ context = module_path
+ else:
+ context = '%s()' % function
+
+ title = '%s crashed with %s in %s' % (
+ path,
+ exception,
+ context
)
+ if message:
+ title += ': %s' % message
+
+ return title
+
# package problem
if self.get('ProblemType') == 'Package' and \
self.has_key('Package'):
@@ -2066,7 +2090,7 @@
subprocess.call(['pgrep', '-x',
NameError: global name 'subprocess' is not defined'''
self.assertEqual(report.standard_title(),
- 'apport-gtk crashed with NameError in ui_present_crash()')
+ "apport-gtk crashed with NameError in ui_present_crash(): global name 'subprocess' is not defined")
# slightly weird Python crash
report = Report()
@@ -2100,6 +2124,30 @@
self.assert_(t.startswith('apport-gtk crashed with'))
self.assert_(t.endswith('setup_chooser()'))
+ # Python crash at top level in module
+ report = Report()
+ report['ExecutablePath'] = '/usr/bin/gnome-about'
+ report['Traceback'] = '''Traceback (most recent call last):
+ File "/usr/bin/gnome-about", line 30, in <module>
+ import pygtk
+ File "/usr/lib/pymodules/python2.6/pygtk.py", line 28, in <module>
+ import nonexistent
+ImportError: No module named nonexistent
+'''
+ self.assertEqual(report.standard_title(),
+ "gnome-about crashed with ImportError in /usr/lib/pymodules/python2.6/pygtk.py: No module named nonexistent")
+
+ # Python crash at top level in main program
+ report = Report()
+ report['ExecutablePath'] = '/usr/bin/dcut'
+ report['Traceback'] = '''Traceback (most recent call last):
+ File "/usr/bin/dcut", line 28, in <module>
+ import nonexistent
+ImportError: No module named nonexistent
+'''
+ self.assertEqual(report.standard_title(),
+ "dcut crashed with ImportError in __main__: No module named nonexistent")
+
# package install problem
report = Report('Package')
report['Package'] = 'bash'
Follow ups