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
Touch seeded packages, 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

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