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

Avoid deprecated load_module() in pkg_resources namespace delaration #2523

Merged
merged 1 commit into from
Jan 9, 2021

Conversation

encukou
Copy link
Contributor

@encukou encukou commented Jan 6, 2021

Summary of changes

Fixes #2493

As I said in the issue,

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.

Pull Request Checklist

  • Changes have tests (existing related tests no longer warn under Python 3.10; warnings are treated as errors by default)
  • News fragment added in changelog.d/.
    (See documentation for details)

@jaraco jaraco merged commit a54d9e6 into pypa:main Jan 9, 2021
@encukou encukou deleted the load_module branch January 11, 2021 09:59
The-Compiler added a commit to qutebrowser/qutebrowser that referenced this pull request Apr 7, 2021
pypa/setuptools#2517
pypa/setuptools#2523
(something in tox/virtualenv probably uses an older setuptools...)

benjaminp/six#352 (not released yet)
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 this pull request may close these issues.

DeprecationWarning with load_module on Python 3.10 in pkg_resources._handle_ns
2 participants