Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Forward compatibility][BUG] pkg_resources.extern.VendorImporter lacks exec_module() method #2481

Closed
webknjaz opened this issue Dec 11, 2020 · 9 comments · Fixed by #2517
Closed
Labels
bug help wanted Needs Implementation Issues that are ready to be implemented.

Comments

@webknjaz
Copy link
Member

webknjaz commented Dec 11, 2020

This causes an ImportWarning that effectively explodes in envs with a strict warning handling (filterwarnings = error) — like pytest — under Python 3.10-dev that ships setuptools v47.1.0. But I checked that the importer is still missing that method.
The simple repro is:

$ python3.10 -W error -c 'import pkg_resources' 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "~/.pyenv/versions/3.10-dev/lib/python3.10/site-packages/pkg_resources/__init__.py", line 57, in <module>
    from pkg_resources.extern import six
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1005, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 681, in _load_unlocked
ImportWarning: VendorImporter.exec_module() not found; falling back to load_module()

Example failure: https://github.com/cherrypy/cheroot/runs/1533924692?check_suite_focus=true#step:14:226.

@webknjaz webknjaz changed the title pkg_resources.extern.VendorImporter lacks exec_module [Forward compatibility][BUG] pkg_resources.extern.VendorImporter lacks exec_module() method Dec 11, 2020
@webknjaz
Copy link
Member Author

webknjaz commented Dec 11, 2020

Ignoring the warning in this module reveals another warning like that originating from pkg_resources._vendor.six._SixMetaPathImporter:

$ python3.10 -W error -W 'ignore:VendorImporter.exec_module() not found; falling back to load_module():ImportWarning' -c 'import pkg_resources'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "~/.pyenv/versions/3.10-dev/lib/python3.10/site-packages/pkg_resources/__init__.py", line 58, in <module>
    from pkg_resources.extern.six.moves import map, filter
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1005, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 682, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 642, in _load_backward_compatible
  File "~/.pyenv/versions/3.10-dev/lib/python3.10/site-packages/pkg_resources/extern/__init__.py", line 43, in load_module
    __import__(extant)
  File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1005, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 681, in _load_unlocked
ImportWarning: _SixMetaPathImporter.exec_module() not found; falling back to load_module()

webknjaz added a commit to cherrypy/cheroot that referenced this issue Dec 11, 2020
This change temporarily ignores import warnings coming from the custom
import hooks that both `pkg_resources.extern` and `six` (vendored as
`pkg_resources._vendor.six`) implement. They both a missing the
`exec_module()` method and Python 3.10 emits `ImportWarning`s if it is
not there.

Ref: pypa/setuptools#2481
@webknjaz webknjaz added bug help wanted Needs Implementation Issues that are ready to be implemented. labels Dec 11, 2020
@webknjaz
Copy link
Member Author

Apparently, @brettcannon has already reported the same thing to six 3 weeks ago: benjaminp/six#341.

@webknjaz
Copy link
Member Author

Interesting observation: I normally ignore specific warnings with a module-level restriction that filterwarnings allows but it doesn't work for these dynamically injected modules. And so I'm forced to apply a more broad ignore. This sounds like something CPython could attempt to fix on their side...

@webknjaz
Copy link
Member Author

Root cause: the original deprecation got introduced in CPython via https://bugs.python.org/issue26131 and python/cpython#23469.

@webknjaz
Copy link
Member Author

Ignoring the warning in this module reveals another warning like that originating from pkg_resources._vendor.six._SixMetaPathImporter:

This part looks irrelevant to master because six seems to have been removed about 4 months ago.

@blueyed
Copy link

blueyed commented Dec 19, 2020

Related: #2493

@hroncok
Copy link
Contributor

hroncok commented Dec 30, 2020

This breaks many other packages, including pytest, jinja2. See https://bugzilla.redhat.com/showdependencytree.cgi?id=1911607&hide_resolved=0

@hroncok
Copy link
Contributor

hroncok commented Dec 30, 2020

I've drafted #2517 but I am sure that's not the correct path froward.

hroncok added a commit to hroncok/setuptools that referenced this issue Jan 4, 2021
hroncok added a commit to hroncok/setuptools that referenced this issue Jan 4, 2021
hroncok added a commit to hroncok/setuptools that referenced this issue Jan 4, 2021
@hroncok
Copy link
Contributor

hroncok commented Apr 8, 2021

A followup: #2632

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted Needs Implementation Issues that are ready to be implemented.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants