summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-08-06 20:34:44 (GMT)
committerBrett Cannon <brett@python.org>2012-08-06 20:34:44 (GMT)
commitcb4996afe4952e219d13bbb5a84162ab1aaa6887 (patch)
treec4d7cd79f10e23fc3c369d6d5636e0ed24182acb /Lib/importlib
parent638de338e66b6e84a98c7bd8f6f6959575b53c51 (diff)
downloadcpython-cb4996afe4952e219d13bbb5a84162ab1aaa6887.zip
cpython-cb4996afe4952e219d13bbb5a84162ab1aaa6887.tar.gz
cpython-cb4996afe4952e219d13bbb5a84162ab1aaa6887.tar.bz2
Issue #15471: Don't use mutable object as default values for the
parameters of importlib.__import__().
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index b9b35ec..4f61a5b 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1587,7 +1587,7 @@ def _get_supported_file_loaders():
return [extensions, source, bytecode]
-def __import__(name, globals={}, locals={}, fromlist=[], level=0):
+def __import__(name, globals=None, locals=None, fromlist=(), level=0):
"""Import a module.
The 'globals' argument is used to infer where the import is occuring from
@@ -1601,7 +1601,8 @@ def __import__(name, globals={}, locals={}, fromlist=[], level=0):
if level == 0:
module = _gcd_import(name)
else:
- package = _calc___package__(globals)
+ globals_ = globals if globals is not None else {}
+ package = _calc___package__(globals_)
module = _gcd_import(name, package, level)
if not fromlist:
# Return up to the first dot in 'name'. This is complicated by the fact