aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndřej Súkup <mimi1vx@users.noreply.github.com>2019-11-15 08:52:35 +0100
committerGitHub <noreply@github.com>2019-11-15 08:52:35 +0100
commitbbf825eee764cae0bc44077ccc957a733d53d095 (patch)
tree88741e4705ce50bbc511f6e657fa1c7065ef4cfe
parent55994609aaebecdfb7b8da4945ce0ed799d344c9 (diff)
downloadexternal_python_setuptools-bbf825eee764cae0bc44077ccc957a733d53d095.tar.gz
external_python_setuptools-bbf825eee764cae0bc44077ccc957a733d53d095.tar.bz2
external_python_setuptools-bbf825eee764cae0bc44077ccc957a733d53d095.zip
Fix _imp module behaviour if is defined paths in find_spec call
fixes #1896
-rw-r--r--setuptools/_imp.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/setuptools/_imp.py b/setuptools/_imp.py
index a3cce9b2..6ccec579 100644
--- a/setuptools/_imp.py
+++ b/setuptools/_imp.py
@@ -19,7 +19,10 @@ PY_FROZEN = 7
def find_module(module, paths=None):
"""Just like 'imp.find_module()', but with package support"""
- spec = importlib.util.find_spec(module, paths)
+ if isinstance(paths, list):
+ spec = importlib.machinery.PathFinder().find_spec(module, paths)
+ else:
+ spec = importlib.util.find_spec(module, paths)
if spec is None:
raise ImportError("Can't find %s" % module)
if not spec.has_location and hasattr(spec, 'submodule_search_locations'):
@@ -60,14 +63,20 @@ def find_module(module, paths=None):
def get_frozen_object(module, paths=None):
- spec = importlib.util.find_spec(module, paths)
+ if isinstance(paths, list):
+ spec = importlib.machinery.PathFinder().find_spec(module, paths)
+ else:
+ spec = importlib.util.find_spec(module, paths)
if not spec:
raise ImportError("Can't find %s" % module)
return spec.loader.get_code(module)
def get_module(module, paths, info):
- spec = importlib.util.find_spec(module, paths)
+ if isinstance(paths, list):
+ spec = importlib.machinery.PathFinder().find_spec(module, paths)
+ else:
+ spec = importlib.util.find_spec(module, paths)
if not spec:
raise ImportError("Can't find %s" % module)
return module_from_spec(spec)