pathlib: Fix module path used when using importlib with namespaces
This commit is contained in:
parent
5af46f3d4e
commit
7ef189757e
|
@ -540,7 +540,7 @@ def import_path(
|
||||||
# Try to import this module using the standard import mechanisms, but
|
# Try to import this module using the standard import mechanisms, but
|
||||||
# without touching sys.path.
|
# without touching sys.path.
|
||||||
try:
|
try:
|
||||||
pkg_root, module_name = resolve_pkg_root_and_module_name(
|
_, module_name = resolve_pkg_root_and_module_name(
|
||||||
path, consider_namespace_packages=consider_namespace_packages
|
path, consider_namespace_packages=consider_namespace_packages
|
||||||
)
|
)
|
||||||
except CouldNotResolvePathError:
|
except CouldNotResolvePathError:
|
||||||
|
@ -551,7 +551,7 @@ def import_path(
|
||||||
return sys.modules[module_name]
|
return sys.modules[module_name]
|
||||||
|
|
||||||
mod = _import_module_using_spec(
|
mod = _import_module_using_spec(
|
||||||
module_name, path, pkg_root, insert_modules=False
|
module_name, path, path.parent, insert_modules=False
|
||||||
)
|
)
|
||||||
if mod is not None:
|
if mod is not None:
|
||||||
return mod
|
return mod
|
||||||
|
|
Loading…
Reference in New Issue