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
817641a3
Commit
817641a3
authored
Mar 04, 2009
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename importlib.util.set___package__ to set_package.
parent
bada715c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
9 deletions
+9
-9
Doc/library/importlib.rst
Doc/library/importlib.rst
+1
-1
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+4
-4
Lib/importlib/test/test_util.py
Lib/importlib/test/test_util.py
+3
-3
Lib/importlib/util.py
Lib/importlib/util.py
+1
-1
No files found.
Doc/library/importlib.rst
View file @
817641a3
...
...
@@ -185,7 +185,7 @@ an :term:`importer`.
loader should initialize as specified by :pep:`302`.
.. function:: set_
__package__
(method)
.. function:: set_
package
(method)
A :term:`decorator` for a :term:`loader` to set the :attr:`__package__`
attribute on the module returned by the loader. If :attr:`__package__` is
...
...
Lib/importlib/_bootstrap.py
View file @
817641a3
...
...
@@ -97,7 +97,7 @@ def wrap(new, old):
new
.
__dict__
.
update
(
old
.
__dict__
)
def
set_
__package__
(
fxn
):
def
set_
package
(
fxn
):
"""Set __package__ on the returned module."""
def
wrapper
(
*
args
,
**
kwargs
):
module
=
fxn
(
*
args
,
**
kwargs
)
...
...
@@ -131,7 +131,7 @@ class BuiltinImporter:
return
cls
if
imp
.
is_builtin
(
fullname
)
else
None
@
classmethod
@
set_
__package__
@
set_
package
def
load_module
(
cls
,
fullname
):
"""Load a built-in module."""
if
fullname
not
in
sys
.
builtin_module_names
:
...
...
@@ -160,7 +160,7 @@ class FrozenImporter:
return
cls
if
imp
.
is_frozen
(
fullname
)
else
None
@
classmethod
@
set_
__package__
@
set_
package
def
load_module
(
cls
,
fullname
):
"""Load a frozen module."""
if
cls
.
find_module
(
fullname
)
is
None
:
...
...
@@ -248,7 +248,7 @@ class _ExtensionFileLoader:
raise
ValueError
(
"extension modules cannot be packages"
)
@
check_name
@
set_
__package__
@
set_
package
def
load_module
(
self
,
fullname
):
"""Load an extension module."""
is_reload
=
fullname
in
sys
.
modules
...
...
Lib/importlib/test/test_util.py
View file @
817641a3
...
...
@@ -63,13 +63,13 @@ class ModuleForLoaderTests(unittest.TestCase):
class
SetPackageTests
(
unittest
.
TestCase
):
"""Tests for importlib.util.set_
__package__
."""
"""Tests for importlib.util.set_
package
."""
def
verify
(
self
,
module
,
expect
):
"""Verify the module has the expected value for __package__ after
passing through set_
__package__
."""
passing through set_
package
."""
fxn
=
lambda
:
module
wrapped
=
util
.
set_
__package__
(
fxn
)
wrapped
=
util
.
set_
package
(
fxn
)
wrapped
()
self
.
assert_
(
hasattr
(
module
,
'__package__'
))
self
.
assertEqual
(
expect
,
module
.
__package__
)
...
...
Lib/importlib/util.py
View file @
817641a3
"""Utility code for constructing importers, etc."""
from
._bootstrap
import
module_for_loader
from
._bootstrap
import
set_
__package__
from
._bootstrap
import
set_
package
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