Skip to content

Commit

Permalink
Merge pull request #2918 from nitzmahone/fix_nonlegacy_loader
Browse files Browse the repository at this point in the history
fix `pkg_resources` import failures w/ py3-only loaders
  • Loading branch information
jaraco committed Jan 11, 2022
2 parents 464568d + 9caec1f commit 8fd31fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/2918.misc.rst
@@ -0,0 +1 @@
Correct support for Python 3 native loaders.
4 changes: 3 additions & 1 deletion pkg_resources/__init__.py
Expand Up @@ -2205,12 +2205,14 @@ def _handle_ns(packageName, path_item):

# use find_spec (PEP 451) and fall-back to find_module (PEP 302)
try:
loader = importer.find_spec(packageName).loader
spec = importer.find_spec(packageName)
except AttributeError:
# capture warnings due to #1111
with warnings.catch_warnings():
warnings.simplefilter("ignore")
loader = importer.find_module(packageName)
else:
loader = spec.loader if spec else None

if loader is None:
return None
Expand Down

0 comments on commit 8fd31fc

Please sign in to comment.