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
b282b3d8
Commit
b282b3d8
authored
Dec 10, 2013
by
Eric Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #18864: Add a setter for ModuleSpec.has_location.
parent
85cce1ea
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2932 additions
and
2910 deletions
+2932
-2910
Doc/library/importlib.rst
Doc/library/importlib.rst
+1
-1
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+4
-0
Lib/test/test_importlib/test_spec.py
Lib/test/test_importlib/test_spec.py
+7
-0
Misc/NEWS
Misc/NEWS
+2
-0
Python/importlib.h
Python/importlib.h
+2918
-2909
No files found.
Doc/library/importlib.rst
View file @
b282b3d8
...
...
@@ -901,7 +901,7 @@ find and load modules.
.. attribute:: has_location
(Read-only)
Boolean indicating whether or not the module'
s
"origin"
Boolean indicating whether or not the module'
s
"origin"
attribute
refers
to
a
loadable
location
.
:
mod
:`
importlib
.
util
`
--
Utility
code
for
importers
...
...
Lib/importlib/_bootstrap.py
View file @
b282b3d8
...
...
@@ -841,6 +841,10 @@ class ModuleSpec:
def
has_location
(
self
):
return
self
.
_set_fileattr
@
has_location
.
setter
def
has_location
(
self
,
value
):
self
.
_set_fileattr
=
bool
(
value
)
def
spec_from_loader
(
name
,
loader
,
*
,
origin
=
None
,
is_package
=
None
):
"""Return a module spec based on various loader methods."""
...
...
Lib/test/test_importlib/test_spec.py
View file @
b282b3d8
...
...
@@ -116,6 +116,13 @@ class ModuleSpecTests:
self
.
assertIs
(
spec
.
cached
,
None
)
self
.
assertFalse
(
spec
.
has_location
)
def
test_has_location_setter
(
self
):
spec
=
self
.
machinery
.
ModuleSpec
(
self
.
name
,
self
.
loader
,
origin
=
'somewhere'
)
self
.
assertFalse
(
spec
.
has_location
)
spec
.
has_location
=
True
self
.
assertTrue
(
spec
.
has_location
)
def
test_equality
(
self
):
other
=
type
(
sys
.
implementation
)(
name
=
self
.
name
,
loader
=
self
.
loader
,
...
...
Misc/NEWS
View file @
b282b3d8
...
...
@@ -105,6 +105,8 @@ Library
- Issue #19698: Removed exec_module() methods from
importlib.machinery.BuiltinImporter and ExtensionFileLoader.
- Issue #18864: Added a setter for ModuleSpec.has_location.
- Fixed _pickle.Unpickler to not fail when loading empty strings as
persistent IDs.
...
...
Python/importlib.h
View file @
b282b3d8
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