summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-06-12 00:38:29 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-06-12 00:38:29 (GMT)
commit5976d975f8f16ebc7f5d218dfdcaf28411a4c0d2 (patch)
tree920f396ebbd5d6ebef4e253c62e5935eda11ebfb /Lib/test
parent313a120ab6515f1bcddb13a9403a857078a9e474 (diff)
downloadcpython-5976d975f8f16ebc7f5d218dfdcaf28411a4c0d2.zip
cpython-5976d975f8f16ebc7f5d218dfdcaf28411a4c0d2.tar.gz
cpython-5976d975f8f16ebc7f5d218dfdcaf28411a4c0d2.tar.bz2
When dealing with __import__ for detecting a global state change made by a
test, make sure to check if __builtins__ is a dict or not. Discovered when running importlib.test.regrtest.
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/regrtest.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 34b743e..8b46f6e 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -859,9 +859,15 @@ class saved_test_environment:
sys.path_hooks[:] = saved_hooks[2]
def get___import__(self):
- return __builtins__.__import__
+ if isinstance(__builtins__, dict):
+ return __builtins__['__import__']
+ else:
+ return __builtins__.__import__
def restore___import__(self, import_):
- __builtins__.__import__ = import_
+ if isinstance(__builtins__, dict):
+ __builtins__['__import__'] = import_
+ else:
+ __builtins__.__import__ = import_
def get_warnings_filters(self):
return id(warnings.filters), warnings.filters, warnings.filters[:]