apport-hackers team mailing list archive
-
apport-hackers team
-
Mailing list archive
-
Message #00109
[Merge] lp:~brian-murray/apport/python-env into lp:apport
Brian Murray has proposed merging lp:~brian-murray/apport/python-env into lp:apport.
Requested reviews:
Apport upstream developers (apport-hackers)
For more details, see:
https://code.launchpad.net/~brian-murray/apport/python-env/+merge/126818
In bug https://bugs.launchpad.net/ubuntu/+source/python3.2/+bug/938869 we are fairly certain that lsb_release is crashing because it is being called with a version of python that is bundled with vmware-installer. It'd be good to know what other crashes may be due to a modified PYTHONPATH or PYTHONHOME.
In the test I also wanted to test for PYTHONHOME in ProcEnviron but I ran into problems setting it and still having the test run.
--
https://code.launchpad.net/~brian-murray/apport/python-env/+merge/126818
Your team Apport upstream developers is requested to review the proposed merge of lp:~brian-murray/apport/python-env into lp:apport.
=== modified file 'apport_python_hook.py'
--- apport_python_hook.py 2012-07-12 15:11:48 +0000
+++ apport_python_hook.py 2012-09-27 22:22:18 +0000
@@ -100,7 +100,7 @@
tb_file = StringIO()
traceback.print_exception(exc_type, exc_obj, exc_tb, file=tb_file)
pr['Traceback'] = tb_file.getvalue().strip()
- pr.add_proc_info()
+ pr.add_proc_info(extraenv=['PYTHONPATH', 'PYTHONHOME'])
pr.add_user_info()
# override the ExecutablePath with the script that was actually running
pr['ExecutablePath'] = binary
=== modified file 'test/test_python_crashes.py'
--- test/test_python_crashes.py 2012-07-12 15:11:48 +0000
+++ test/test_python_crashes.py 2012-09-27 22:22:18 +0000
@@ -48,7 +48,6 @@
''' % (os.getenv('PYTHON', 'python3'), extracode)).encode())
os.close(fd)
os.chmod(script, 0o755)
-
p = subprocess.Popen([script, 'testarg1', 'testarg2'],
stderr=subprocess.PIPE, env=os.environ)
err = p.communicate()[1].decode()
@@ -143,6 +142,24 @@
self.assertTrue('bin/python' in pr['InterpreterPath'])
self.assertTrue(pr['Traceback'].startswith('Traceback'))
+ def test_python_env(self):
+ '''Python environmental variables appear in report'''
+
+ self._test_crash()
+
+ # did we get a report?
+ reports = apport.fileutils.get_new_reports()
+ pr = None
+ self.assertEqual(len(reports), 1, 'crashed Python program produced a report')
+
+ pr = problem_report.ProblemReport()
+ with open(reports[0], 'rb') as f:
+ pr.load(f)
+
+ # check report contents
+ self.assertTrue('PYTHONPATH' in pr['ProcEnviron'],
+ 'report contains PYTHONPATH')
+
def _assert_no_reports(self):
'''Assert that there are no crash reports.'''