apport_python_hook: Crashes if os.getcwd() throws FileNotFoundError
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Apport |
Fix Released
|
Medium
|
Unassigned | ||
apport (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Jammy |
New
|
Medium
|
Unassigned |
Bug Description
Impact
------
The Apport Python hook should be transparent to the user (which is normally the case). Bugs and crashes inside the hook lead to an exception inside the exception which clutters the output and confuse the user. User/Developer need to understand this Python hook and look into the encapsulated stack trace only.
Test Case
---------
1. Create /tmp/getcwd.py with following content:
```
#!/usr/bin/python3
import os
import tempfile
tempdir = tempfile.mkdtemp()
os.chdir(tempdir)
os.rmdir(tempdir)
os.getcwd()
```
2. Make it executable and execute it.
It should produce following output:
```
Traceback (most recent call last):
File "/tmp/getcwd.py", line 9, in <module>
os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
```
instead of:
```
$ /tmp/getcwd.py
Traceback (most recent call last):
File "/tmp/getcwd.py", line 9, in <module>
os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/
binary = os.path.
FileNotFoundError: [Errno 2] No such file or directory
Original exception was:
Traceback (most recent call last):
File "/tmp/getcwd.py", line 9, in <module>
os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
```
Another related issue: bug #1979637
Regression Potential
-------
There might be a regression that causes capturing Python exception fail. Then reporting them as bugs to Launchpad or the error tracker would not be possible.
Changed in apport: | |
milestone: | none → 2.22.0 |
status: | New → Triaged |
importance: | Undecided → Medium |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in apport: | |
status: | Fix Committed → Fix Released |
description: | updated |
description: | updated |
Changed in apport (Ubuntu): | |
importance: | Undecided → Medium |
Changed in apport (Ubuntu Jammy): | |
importance: | Undecided → Medium |
Fixed: https:/ /github. com/canonical/ apport/ commit/ ad6d801d264e9a7 430d8d655fd0428 4a8871d68a