summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/importlib/_bootstrap_external.py3
-rw-r--r--Lib/test/test_importlib/test_namespace_pkgs.py6
2 files changed, 9 insertions, 0 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 71fdd0c..146c647 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -1163,6 +1163,9 @@ class _NamespacePath:
def __iter__(self):
return iter(self._recalculate())
+ def __getitem__(self, index):
+ return self._recalculate()[index]
+
def __setitem__(self, index, path):
self._path[index] = path
diff --git a/Lib/test/test_importlib/test_namespace_pkgs.py b/Lib/test/test_importlib/test_namespace_pkgs.py
index 8e4b5d6..a8f95a0 100644
--- a/Lib/test/test_importlib/test_namespace_pkgs.py
+++ b/Lib/test/test_importlib/test_namespace_pkgs.py
@@ -332,6 +332,12 @@ class LoaderTests(NamespacePackageTest):
self.assertIsNone(foo.__spec__.origin)
self.assertIsNone(foo.__file__)
+ def test_path_indexable(self):
+ # bpo-35843
+ import foo
+ expected_path = os.path.join(self.root, 'portion1', 'foo')
+ self.assertEqual(foo.__path__[0], expected_path)
+
if __name__ == "__main__":
unittest.main()