Skip to content

Commit be926f8

Browse files
committed
Drop importlib changes
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent 755818b commit be926f8

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/importlib/_bootstrap_external.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,6 @@ def find_spec(cls, fullname, path=None, target=None):
13111311
# can create the namespace package.
13121312
spec.origin = None
13131313
spec.submodule_search_locations = _NamespacePath(fullname, namespace_path, cls._get_spec)
1314-
spec.loader = NamespaceLoader(fullname, namespace_path, cls._get_spec)
13151314
return spec
13161315
else:
13171316
return None

Lib/modulefinder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ def _find_module(name, path=None):
6666

6767
file_path = spec.origin
6868

69-
if isinstance(spec.loader, importlib.machinery.NamespaceLoader):
69+
# On namespace packages, spec.loader might be None, but
70+
# spec.submodule_search_locations should always be set — check it instead.
71+
#
72+
# TODO: Update the type check once GH-119669 is merged.
73+
# if isinstance(spec.submodule_search_locations, importlib.machinery.NamespacePath):
74+
if 'NamespacePath' in type(spec.submodule_search_locations).__name__:
7075
return None, spec.submodule_search_locations, ("", "", _PKG_DIRECTORY)
7176

7277
if spec.loader.is_package(name): # non-namespace package

0 commit comments

Comments
 (0)