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
3f09d038
Commit
3f09d038
authored
Feb 16, 2012
by
Brett Cannon
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
c39f9306
36bb6658
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
0 deletions
+12
-0
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+2
-0
Lib/importlib/test/import_/test_api.py
Lib/importlib/test/import_/test_api.py
+7
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/importlib/_bootstrap.py
View file @
3f09d038
...
...
@@ -1048,6 +1048,8 @@ def __import__(name, globals={}, locals={}, fromlist=[], level=0):
raise
TypeError
(
"module name must be str, not {}"
.
format
(
type
(
name
)))
if
level
==
0
:
module
=
_gcd_import
(
name
)
elif
level
<
0
:
raise
ValueError
(
'level must be >= 0'
)
else
:
package
=
_calc___package__
(
globals
)
module
=
_gcd_import
(
name
,
package
,
level
)
...
...
Lib/importlib/test/import_/test_api.py
View file @
3f09d038
...
...
@@ -12,6 +12,13 @@ class APITest(unittest.TestCase):
with
self
.
assertRaises
(
TypeError
):
util
.
import_
(
42
)
def
test_negative_level
(
self
):
# Raise ValueError when a negative level is specified.
# PEP 328 did away with sys.module None entries and the ambiguity of
# absolute/relative imports.
with
self
.
assertRaises
(
ValueError
):
util
.
import_
(
'os'
,
globals
(),
level
=-
1
)
def
test_main
():
from
test.support
import
run_unittest
...
...
Misc/NEWS
View file @
3f09d038
...
...
@@ -466,6 +466,9 @@ Core and Builtins
Library
-------
-
Do
away
with
ambiguous
level
values
(
as
suggested
by
PEP
328
)
in
importlib
.
__import__
()
by
raising
ValueError
when
level
<
0.
-
Issue
#
2489
:
pty
.
spawn
could
consume
100
%
cpu
when
it
encountered
an
EOF
.
-
Issue
#
13014
:
Fix
a
possible
reference
leak
in
SSLSocket
.
getpeercert
().
...
...
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