[Bug 1808133] Re: python3-apport emits a deprecation warning

Mikko Rantalainen mikko.rantalainen at peda.net
Thu Feb 28 09:55:14 UTC 2019


Could this be fixed for bionic, too?

$ python3 -Wall -c '1/0'
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, locale, imp
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ZeroDivisionError: division by zero

$ lsb_release -a
LSB Version:	core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.2 LTS
Release:	18.04
Codename:	bionic

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

Title:
  python3-apport emits a deprecation warning

Status in apport package in Ubuntu:
  Fix Released

Bug description:
  python3-apport uses the deprecated module imp. This causes to emitting
  a deprecation warning when run python3 with the -Walways option, and
  even to changing a traceback when run python3 with the -Werror option.

  Example:

  ```
  $ python3 -Walways -c '1/0'
  /usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import fnmatch, glob, traceback, errno, sys, atexit, locale, imp
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  ZeroDivisionError: division by zero
  ```
  ```
  $ python3 -Werror -c '1/0'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  ZeroDivisionError: division by zero
  Error in sys.excepthook:                                                                                                                                                                                                                    
  Traceback (most recent call last):                                                                                                                                                                                                          
    File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook                                                                                                                                                
      from apport.fileutils import likely_packaged, get_recent_crashes                                                                                                                                                                        
    File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>                                                                                                                                                             
      from apport.report import Report                                                                                                                                                                                                        
    File "/usr/lib/python3/dist-packages/apport/report.py", line 13, in <module>
      import fnmatch, glob, traceback, errno, sys, atexit, locale, imp
    File "/usr/lib/python3.6/imp.py", line 33, in <module>
      DeprecationWarning, stacklevel=2)
  DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

  Original exception was:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  ZeroDivisionError: division by zero
  ```

  The -Werror option can be used for catching possible issues, and
  additional output from apport spoils the result.

  ```
  $ python3 -b -Werror -c 'str(b"")'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  BytesWarning: str() on a bytes instance
  Error in sys.excepthook:
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
      from apport.fileutils import likely_packaged, get_recent_crashes
    File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
      from apport.report import Report
    File "/usr/lib/python3/dist-packages/apport/report.py", line 13, in <module>
      import fnmatch, glob, traceback, errno, sys, atexit, locale, imp
    File "/usr/lib/python3.6/imp.py", line 33, in <module>
      DeprecationWarning, stacklevel=2)
  DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

  Original exception was:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  BytesWarning: str() on a bytes instance
  ```

  The solution is to silence DeprecationWarning for `import imp`:

  import warnings
  with warnings.catch_warnings():
      warnings.simplefilter('ignore', DeprecationWarning)
      import imp

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



More information about the foundations-bugs mailing list