aboutsummaryrefslogtreecommitdiffstats
path: root/pkg_resources/__init__.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-03-21 05:41:35 -0400
committerGitHub <noreply@github.com>2020-03-21 05:41:35 -0400
commit17dde199ad37b6f9e911e1edb9d2d303e3238157 (patch)
tree0c2aaff286e53dd148876d1ea6379ea2db9c8998 /pkg_resources/__init__.py
parent42d0d0393e3e8b48cbf4ff2aa5b9de09041e915f (diff)
parent6b5a5872503290d6c90ab18cd72e46776977064a (diff)
downloadexternal_python_setuptools-17dde199ad37b6f9e911e1edb9d2d303e3238157.tar.gz
external_python_setuptools-17dde199ad37b6f9e911e1edb9d2d303e3238157.tar.bz2
external_python_setuptools-17dde199ad37b6f9e911e1edb9d2d303e3238157.zip
Merge pull request #1563 from alhirzel/master
Change find_module to find_spec for py37 compat
Diffstat (limited to 'pkg_resources/__init__.py')
-rw-r--r--pkg_resources/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 88d4bdca..15a4401a 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -2197,10 +2197,14 @@ def _handle_ns(packageName, path_item):
if importer is None:
return None
- # capture warnings due to #1111
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- loader = importer.find_module(packageName)
+ # use find_spec (PEP 451) and fall-back to find_module (PEP 302)
+ try:
+ loader = importer.find_spec(packageName).loader
+ except AttributeError:
+ # capture warnings due to #1111
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ loader = importer.find_module(packageName)
if loader is None:
return None