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

DeprecationWarning with load_module on Python 3.10 in pkg_resources._handle_ns #2493

Closed
blueyed opened this issue Dec 19, 2020 · 2 comments · Fixed by #2523
Closed

DeprecationWarning with load_module on Python 3.10 in pkg_resources._handle_ns #2493

blueyed opened this issue Dec 19, 2020 · 2 comments · Fixed by #2523

Comments

@blueyed
Copy link

blueyed commented Dec 19, 2020

DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead

Code ref:

loader.load_module(packageName)

@hroncok
Copy link
Contributor

hroncok commented Dec 30, 2020

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

@encukou
Copy link
Contributor

encukou commented Jan 6, 2021

As for the calling of load_module in pkg_resources.__init__, it seems to me that the only purpose of the call is to ensure the module is loaded, so that its __path__ can be fixed up using _rebuild_mod_path. The call uses the default loader.

So, it could be replaced by importlib.import_module(packageName). From the load_module docs, the only thing it does in addition to what import_module does is reloading the module if it already exists. To me, that seems like an unintended side effect.
But I could also be off; the docs are written for implementing of loaders, not for calling them.

I'll send a PR.

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.

3 participants