summaryrefslogtreecommitdiff
path: root/pkg_resources
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-01-10 20:44:52 -0500
committerGitHub <noreply@github.com>2022-01-10 20:44:52 -0500
commit8fd31fc941d65ca51057b00f99ea0836c56f2dc7 (patch)
tree0b77b59bb9dff2d3ada94e5b558e7b788f4b62a7 /pkg_resources
parent464568d64469fb1ca9794ef26fe2288f16c15598 (diff)
parent9caec1fe2de94409a5928bc5b60366c83174c769 (diff)
downloadpython-setuptools-git-8fd31fc941d65ca51057b00f99ea0836c56f2dc7.tar.gz
Merge pull request #2918 from nitzmahone/fix_nonlegacy_loader
fix `pkg_resources` import failures w/ py3-only loaders
Diffstat (limited to 'pkg_resources')
-rw-r--r--pkg_resources/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index f98516d1..9cc6b0a4 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -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