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
4b03b686
Commit
4b03b686
authored
Feb 23, 2012
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turn _return_module() into _handle_fromlist().
parent
6858cabb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+25
-25
No files found.
Lib/importlib/_bootstrap.py
View file @
4b03b686
...
...
@@ -1001,7 +1001,7 @@ def _gcd_import(name, package=None, level=0):
return
_find_and_load
(
name
,
_gcd_import
)
def
_
return_module
(
module
,
name
,
fromlist
,
level
,
import_
):
def
_
handle_fromlist
(
module
,
fromlist
,
import_
):
"""Figure out what __import__ should return.
The import_ parameter is a callable which takes the name of module to
...
...
@@ -1010,17 +1010,6 @@ def _return_module(module, name, fromlist, level, import_):
"""
# The hell that is fromlist ...
if
not
fromlist
:
# Return up to the first dot in 'name'. This is complicated by the fact
# that 'name' may be relative.
if
level
==
0
:
return
sys
.
modules
[
name
.
partition
(
'.'
)[
0
]]
elif
not
name
:
return
module
else
:
cut_off
=
len
(
name
)
-
len
(
name
.
partition
(
'.'
)[
0
])
return
sys
.
modules
[
module
.
__name__
[:
-
cut_off
]]
else
:
# If a package was imported, try to import stuff from fromlist.
if
hasattr
(
module
,
'__path__'
):
if
'*'
in
fromlist
and
hasattr
(
module
,
'__all__'
):
...
...
@@ -1066,7 +1055,18 @@ def __import__(name, globals={}, locals={}, fromlist=[], level=0):
else
:
package
=
_calc___package__
(
globals
)
module
=
_gcd_import
(
name
,
package
,
level
)
return
_return_module
(
module
,
name
,
fromlist
,
level
,
_gcd_import
)
if
not
fromlist
:
# Return up to the first dot in 'name'. This is complicated by the fact
# that 'name' may be relative.
if
level
==
0
:
return
sys
.
modules
[
name
.
partition
(
'.'
)[
0
]]
elif
not
name
:
return
module
else
:
cut_off
=
len
(
name
)
-
len
(
name
.
partition
(
'.'
)[
0
])
return
sys
.
modules
[
module
.
__name__
[:
-
cut_off
]]
else
:
return
_handle_fromlist
(
module
,
fromlist
,
_gcd_import
)
def
_setup
(
sys_module
,
imp_module
):
...
...
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