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

Implement create_module() and exec_module() for _SixMetaPathImporter #341

Closed
brettcannon opened this issue Nov 21, 2020 · 8 comments · Fixed by #343
Closed

Implement create_module() and exec_module() for _SixMetaPathImporter #341

brettcannon opened this issue Nov 21, 2020 · 8 comments · Fixed by #343

Comments

@brettcannon
Copy link
Contributor

Use of load_module() when exec_module() is not defined will raise an ImportWarning in Python 3.10.

@frenzymadness
Copy link

@webknjaz
Copy link
Contributor

Extra context: pypa/setuptools#2481.

@webknjaz
Copy link
Contributor

Reproducer:

$ python3.10 -W error -c 'import six.moves.urllib_parse'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  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
Copy link
Contributor

pytest workaround 👇

Here's an example of how to suppress the warning until fixed: cherrypy/cheroot@5fbcb25

@frenzymadness
Copy link

Honestly, this is causing us a lot of problems because we are already testing all Python packages in Fedora with the latest Python 3.10. It would be great if somebody who understands the magic of these methods proposes a fix. The warning can be suppressed by we are not able to do it in hundreds of packages and we'd very like to fix the core problem.

If nobody with a better understanding do it, I'll take a look next week.

@webknjaz
Copy link
Contributor

I've tried the look into this yesterday but there's no clear examples of implementing the required methods (there's +1 extra method necessary).

@frenzymadness if you have a centralized place in the infra, you could try to use a PYTHONWARNINGS env var for that.

@vstinner
Copy link
Contributor

To reproduce the issue:

$ python3.10 -Werror -c 'from six.moves import _thread'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  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()

@vstinner
Copy link
Contributor

I wrote PR #343 to fix this issue.

benjaminp added a commit that referenced this issue Jan 3, 2021
Fixes #341.

Co-authored-by: Benjamin Peterson <benjamin@python.org>
The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Jan 26, 2021
Seems to be raised when importing six (via tldextract/requests/urllib)
on Python 3.10: benjaminp/six#341

See #6068
The-Compiler added a commit to The-Compiler/pytest that referenced this issue Apr 14, 2021
It currently breaks all builds and even after pytest-dev#8540 it looks like tests
still fail because of benjaminp/six#341

As a hotfix, mark it as experimental until everything is fixed, so that
our CI isn't all red.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants