apport_python_hook: FileNotFoundError if cwd was deleted
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Apport |
Fix Released
|
Low
|
Unassigned | ||
apport (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Jammy |
Confirmed
|
Undecided
|
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
---------
Run following shell script:
```sh
echo "raise ValueError()" > /tmp/failure.py
mkdir /tmp/foo
cd /tmp/foo/
rmdir /tmp/foo/
python3 ../failure.py
```
It should only print following stacktrace:
```
Traceback (most recent call last):
File "../failure.py", line 1, in <module>
raise ValueError()
ValueError
```
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.
Original Description
-------
The script should only show a ValueError, but apport_
```
Traceback (most recent call last):
File "../failure.py", line 1, in <module>
raise ValueError()
ValueError
Error in sys.excepthook:
Traceback (most recent call last):
File "<frozen importlib.
KeyError: '..'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/
import apt_pkg
File "<frozen importlib.
File "<frozen importlib.
File "<frozen importlib.
File "<frozen importlib.
File "<frozen importlib.
File "<frozen importlib.
File "<frozen importlib.
File "<frozen importlib.
File "<frozen importlib.
FileNotFoundError: [Errno 2] No such file or directory
Original exception was:
Traceback (most recent call last):
File "../failure.py", line 1, in <module>
raise ValueError()
ValueError
```
Changed in apport: | |
status: | New → Triaged |
milestone: | none → 2.22.0 |
importance: | Undecided → Low |
Changed in apport: | |
status: | Fix Committed → Fix Released |
description: | updated |
description: | updated |
Fixed: https:/ /github. com/canonical/ apport/ commit/ 97f3e56d6d43a43 79bc7b5b3a6e4f5 0222633578