[Bug 1979637] [NEW] apport_python_hook: FileNotFoundError if cwd was deleted

Benjamin Drung 1979637 at bugs.launchpad.net
Thu Jun 23 10:39:04 UTC 2022


Public bug reported:

Run following shell script:

```sh
echo "raise ValueError()" > /tmp/failure.py
mkdir /tmp/foo
cd /tmp/foo/
rmdir /tmp/foo/
python3 ../failure.py
```

Python should only show a ValueError, but apport_python_hook.py crashes:

```
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._bootstrap_external>", line 1372, in _path_importer_cache
KeyError: '..'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 55, in apport_excepthook
    import apt_pkg
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 945, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1439, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1408, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1374, in _path_importer_cache
  File "<frozen importlib._bootstrap_external>", line 1350, in _path_hooks
  File "<frozen importlib._bootstrap_external>", line 1632, in path_hook_for_FileFinder
  File "<frozen importlib._bootstrap_external>", line 1505, in __init__
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
```

** Affects: apport
     Importance: Low
         Status: Triaged

** Affects: apport (Ubuntu)
     Importance: Undecided
         Status: New

** Changed in: apport
       Status: New => Triaged

** Changed in: apport
    Milestone: None => 2.22.0

** Changed in: apport
   Importance: Undecided => Low

** Also affects: apport (Ubuntu)
   Importance: Undecided
       Status: New

-- 
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/1979637

Title:
  apport_python_hook: FileNotFoundError if cwd was deleted

Status in Apport:
  Triaged
Status in apport package in Ubuntu:
  New

Bug description:
  Run following shell script:

  ```sh
  echo "raise ValueError()" > /tmp/failure.py
  mkdir /tmp/foo
  cd /tmp/foo/
  rmdir /tmp/foo/
  python3 ../failure.py
  ```

  Python should only show a ValueError, but apport_python_hook.py
  crashes:

  ```
  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._bootstrap_external>", line 1372, in _path_importer_cache
  KeyError: '..'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 55, in apport_excepthook
      import apt_pkg
    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 945, in _find_spec
    File "<frozen importlib._bootstrap_external>", line 1439, in find_spec
    File "<frozen importlib._bootstrap_external>", line 1408, in _get_spec
    File "<frozen importlib._bootstrap_external>", line 1374, in _path_importer_cache
    File "<frozen importlib._bootstrap_external>", line 1350, in _path_hooks
    File "<frozen importlib._bootstrap_external>", line 1632, in path_hook_for_FileFinder
    File "<frozen importlib._bootstrap_external>", line 1505, in __init__
  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
  ```

To manage notifications about this bug go to:
https://bugs.launchpad.net/apport/+bug/1979637/+subscriptions




More information about the foundations-bugs mailing list