Commit 948b3f41 authored by Jason R. Coombs's avatar Jason R. Coombs

Rely on rpartition.

parent 12b9f825
......@@ -2156,9 +2156,9 @@ def declare_namespace(packageName):
return
path = sys.path
parent = None
if '.' in packageName:
parent = '.'.join(packageName.split('.')[:-1])
parent, _, _ = packageName.rpartition('.')
if parent:
declare_namespace(parent)
if parent not in _namespace_packages:
__import__(parent)
......@@ -2169,7 +2169,7 @@ def declare_namespace(packageName):
# Track what packages are namespaces, so when new path items are added,
# they can be updated
_namespace_packages.setdefault(parent, []).append(packageName)
_namespace_packages.setdefault(parent or None, []).append(packageName)
_namespace_packages.setdefault(packageName, [])
for path_item in path:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment