Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ab9b31f9
Commit
ab9b31f9
authored
Mar 08, 2019
by
Anthony Sottile
Committed by
Miss Islington (bot)
Mar 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35843: Implement __getitem__ for _NamespacePath (GH-11690)
parent
8a1bab92
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
888 additions
and
869 deletions
+888
-869
Lib/importlib/_bootstrap_external.py
Lib/importlib/_bootstrap_external.py
+3
-0
Lib/test/test_importlib/test_namespace_pkgs.py
Lib/test/test_importlib/test_namespace_pkgs.py
+6
-0
Misc/NEWS.d/next/Library/2019-01-28-10-19-40.bpo-35843.7rXGQE.rst
...S.d/next/Library/2019-01-28-10-19-40.bpo-35843.7rXGQE.rst
+1
-0
Python/importlib_external.h
Python/importlib_external.h
+878
-869
No files found.
Lib/importlib/_bootstrap_external.py
View file @
ab9b31f9
...
@@ -1163,6 +1163,9 @@ class _NamespacePath:
...
@@ -1163,6 +1163,9 @@ class _NamespacePath:
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
_recalculate
())
return
iter
(
self
.
_recalculate
())
def
__getitem__
(
self
,
index
):
return
self
.
_recalculate
()[
index
]
def
__setitem__
(
self
,
index
,
path
):
def
__setitem__
(
self
,
index
,
path
):
self
.
_path
[
index
]
=
path
self
.
_path
[
index
]
=
path
...
...
Lib/test/test_importlib/test_namespace_pkgs.py
View file @
ab9b31f9
...
@@ -332,6 +332,12 @@ class LoaderTests(NamespacePackageTest):
...
@@ -332,6 +332,12 @@ class LoaderTests(NamespacePackageTest):
self
.
assertIsNone
(
foo
.
__spec__
.
origin
)
self
.
assertIsNone
(
foo
.
__spec__
.
origin
)
self
.
assertIsNone
(
foo
.
__file__
)
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__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
Misc/NEWS.d/next/Library/2019-01-28-10-19-40.bpo-35843.7rXGQE.rst
0 → 100644
View file @
ab9b31f9
Implement ``__getitem__`` for ``_NamespacePath``. Patch by Anthony Sottile.
Python/importlib_external.h
View file @
ab9b31f9
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment