Skip to content

DeprecationWarning for imp module triggered when run with -Werror #1403

Description

@johnthagen

Testing with -Werror is convenient for CI testing so that warnings can be quickly identified and corrected rather than staying dormant.

With Python 3.5.1 if you execute with -Werror you receive a PendingDeprecationWarning because imp has been deprecated since Python 3.4.

Edit: As of Python 3.6 this is now a full DeprecationWarning.

The code causing the issue is:

To reproduce:

$ python -Werror -m pytest test.py
Traceback (most recent call last):
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\site-packages\pytest.py", line 16, in <module>
    import pytest
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\site-packages\pytest.py", line 27, in <module>
    _preloadplugins() # to populate pytest.* namespace so help(pytest) works
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\site-packages\_pytest\config.py", line 75, in _preloadplugins
    _preinit.append(get_config())
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\site-packages\_pytest\config.py", line 84, in get_config
    pluginmanager.import_plugin(spec)
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\site-packages\_pytest\config.py", line 384, in import_plugin
    __import__(importspec)
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\site-packages\_pytest\main.py", line 6, in <module>
    import os, sys, imp
  File "C:\Users\John Hagen\AppData\Local\Programs\Python\Python35\lib\imp.py", line 33, in <module>
    PendingDeprecationWarning, stacklevel=2)
PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
$ pip -V
pip 8.0.2
$ pip list
...
pytest (2.8.7)

This was tested on Windows 10 x64.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: warningsrelated to the warnings builtin pluginstatus: help wanteddevelopers would like help from experts on this topic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions