mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-32303 - Consistency fixes for namespace loaders (GH-5481) (#5503)
* Make sure ``__spec__.loader`` matches ``__loader__`` for namespace packages.
* Make sure ``__spec__.origin` matches ``__file__`` for namespace packages.
https://bugs.python.org/issue32303
https://bugs.python.org/issue32305
(cherry picked from commit bbbcf8693b
)
Co-authored-by: Barry Warsaw <barry@python.org>
This commit is contained in:
parent
2b5937ec0a
commit
a23d30f64b
10 changed files with 1478 additions and 1436 deletions
|
@ -1276,9 +1276,9 @@ class PathFinder:
|
|||
elif spec.loader is None:
|
||||
namespace_path = spec.submodule_search_locations
|
||||
if namespace_path:
|
||||
# We found at least one namespace path. Return a
|
||||
# spec which can create the namespace package.
|
||||
spec.origin = 'namespace'
|
||||
# We found at least one namespace path. Return a spec which
|
||||
# can create the namespace package.
|
||||
spec.origin = None
|
||||
spec.submodule_search_locations = _NamespacePath(fullname, namespace_path, cls._get_spec)
|
||||
return spec
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue