[Bug 1977954] Re: apport_python_hook: Crashes if os.getcwd() throws FileNotFoundError
Benjamin Drung
1977954 at bugs.launchpad.net
Thu Jun 23 13:11:35 UTC 2022
** Also affects: apport (Ubuntu)
Importance: Undecided
Status: New
** Description changed:
Example code:
```
#!/usr/bin/python3
import os
+ import tempfile
- d = "/tmp/foobar"
- os.mkdir(d)
- os.chdir(d)
- os.rmdir(d)
- print(os.getcwd())
+ tempdir = tempfile.mkdtemp()
+ os.chdir(tempdir)
+ os.rmdir(tempdir)
+ os.getcwd()
```
Once executed:
```
/tmp/getcwd.py
Traceback (most recent call last):
File "/tmp/getcwd.py", line 9, in <module>
print(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 76, in apport_excepthook
binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0]))
FileNotFoundError: [Errno 2] No such file or directory
Original exception was:
Traceback (most recent call last):
File "/tmp/getcwd.py", line 9, in <module>
print(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory
```
Another related issue: bug #1979637
** Description changed:
Example code:
```
#!/usr/bin/python3
import os
import tempfile
tempdir = tempfile.mkdtemp()
os.chdir(tempdir)
os.rmdir(tempdir)
os.getcwd()
```
Once executed:
```
- /tmp/getcwd.py
+ $ /tmp/getcwd.py
Traceback (most recent call last):
- File "/tmp/getcwd.py", line 9, in <module>
- print(os.getcwd())
+ 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/python3/dist-packages/apport_python_hook.py", line 76, in apport_excepthook
- binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0]))
+ File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 76, in apport_excepthook
+ binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0]))
FileNotFoundError: [Errno 2] No such file or directory
Original exception was:
Traceback (most recent call last):
- File "/tmp/getcwd.py", line 9, in <module>
- print(os.getcwd())
+ File "/tmp/getcwd.py", line 9, in <module>
+ os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
```
Another related issue: bug #1979637
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to apport in Ubuntu.
https://bugs.launchpad.net/bugs/1977954
Title:
apport_python_hook: Crashes if os.getcwd() throws FileNotFoundError
Status in Apport:
Triaged
Status in apport package in Ubuntu:
New
Bug description:
Example code:
```
#!/usr/bin/python3
import os
import tempfile
tempdir = tempfile.mkdtemp()
os.chdir(tempdir)
os.rmdir(tempdir)
os.getcwd()
```
Once executed:
```
$ /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/python3/dist-packages/apport_python_hook.py", line 76, in apport_excepthook
binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0]))
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
To manage notifications about this bug go to:
https://bugs.launchpad.net/apport/+bug/1977954/+subscriptions
More information about the foundations-bugs
mailing list