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
da9cf0ee
Commit
da9cf0ee
authored
Feb 01, 2013
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #17098: Be more stringent of setting __loader__ on early imported
modules. Also made test more rigorous.
parent
e7387b47
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
310 additions
and
294 deletions
+310
-294
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+5
-2
Lib/test/test_importlib/test_api.py
Lib/test/test_importlib/test_api.py
+6
-0
Python/importlib.h
Python/importlib.h
+299
-292
No files found.
Lib/importlib/_bootstrap.py
View file @
da9cf0ee
...
...
@@ -1704,10 +1704,13 @@ def _setup(sys_module, _imp_module):
BYTECODE_SUFFIXES
=
DEBUG_BYTECODE_SUFFIXES
module_type
=
type
(
sys
)
for
module
in
sys
.
modules
.
value
s
():
for
name
,
module
in
sys
.
modules
.
item
s
():
if
isinstance
(
module
,
module_type
):
if
not
hasattr
(
module
,
'__loader__'
):
module
.
__loader__
=
BuiltinImporter
if
name
in
sys
.
builtin_module_names
:
module
.
__loader__
=
BuiltinImporter
elif
_imp
.
is_frozen
(
name
):
module
.
__loader__
=
FrozenImporter
self_module
=
sys
.
modules
[
__name__
]
for
builtin_name
in
(
'_io'
,
'_warnings'
,
'builtins'
,
'marshal'
):
...
...
Lib/test/test_importlib/test_api.py
View file @
da9cf0ee
...
...
@@ -184,6 +184,12 @@ class StartupTests(unittest.TestCase):
if
isinstance
(
module
,
types
.
ModuleType
):
self
.
assertTrue
(
hasattr
(
module
,
'__loader__'
),
'{!r} lacks a __loader__ attribute'
.
format
(
name
))
if
name
in
sys
.
builtin_module_names
:
self
.
assertEqual
(
importlib
.
machinery
.
BuiltinImporter
,
module
.
__loader__
)
elif
imp
.
is_frozen
(
name
):
self
.
assertEqual
(
importlib
.
machinery
.
FrozenImporter
,
module
.
__loader__
)
def
test_main
():
from
test.support
import
run_unittest
...
...
Python/importlib.h
View file @
da9cf0ee
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