** Description changed:

+ 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()
+   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/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
  
  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.

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, 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:
  Fix Released
Status in apport package in Ubuntu:
  Fix Released
Status in apport source package in Jammy:
  New

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

  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.

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


-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to