GrahamDumpleton / wrapt

A Python module for decorators, wrappers and monkey patching.
BSD 2-Clause "Simplified" License
2.04k stars 230 forks source link

Python 3.10 `ImportWarning: ImportHookFinder.find_spec() not found...` #200

Closed Kyle-Verhoog closed 2 years ago

Kyle-Verhoog commented 2 years ago

Running the repro here: https://gist.github.com/Kyle-Verhoog/965752b7863f007a8c11fcc75383301e

Results in

$ python3.10 -Wall repro.py
<frozen importlib._bootstrap>:914: ImportWarning: ImportHookFinder.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: ImportHookFinder.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:671: ImportWarning: _ImportHookChainedLoader.exec_module() not found; falling back to load_module()
<frozen importlib._bootstrap>:283: DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead

The relevant entry in the Python 3.10 release notes:

Starting in this release, there will be a concerted effort to begin cleaning up old import semantics that were kept for Python 2.7 compatibility. Specifically, find_loader()/find_module() (superseded by find_spec()), load_module() (superseded by exec_module()), module_repr() (which the import system takes care of for you), the package attribute (superseded by spec.parent), the loader attribute (superseded by spec.loader), and the cached attribute (superseded by spec.cached) will slowly be removed (as well as other classes and methods in importlib). ImportWarning and/or DeprecationWarning will be raised as appropriate to help identify code which needs updating during this transition.

It looks like ImportHookFinder has to implement find_spec().

GrahamDumpleton commented 2 years ago

Hopefully fixed in 1.14.0. Let me know if still occurring.