diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2018-09-14 13:35:26 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2018-09-14 13:48:01 -0400 |
commit | 948b3f41f9079a1c3afd3a409389d90346ec3bff (patch) | |
tree | 194392bb99eeb69151af73d6442dd73aa8f90295 /pkg_resources | |
parent | 12b9f825c347e842f581de89539d1bf0c582e108 (diff) | |
download | external_python_setuptools-948b3f41f9079a1c3afd3a409389d90346ec3bff.tar.gz external_python_setuptools-948b3f41f9079a1c3afd3a409389d90346ec3bff.tar.bz2 external_python_setuptools-948b3f41f9079a1c3afd3a409389d90346ec3bff.zip |
Rely on rpartition.
Diffstat (limited to 'pkg_resources')
-rw-r--r-- | pkg_resources/__init__.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 3f776e46..33f86987 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -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: |