]> granicus.if.org Git - python/commitdiff
Switch the __import__ state check from using __builtins__ to builtins to be
authorBrett Cannon <bcannon@gmail.com>
Mon, 14 Jun 2010 22:22:54 +0000 (22:22 +0000)
committerBrett Cannon <bcannon@gmail.com>
Mon, 14 Jun 2010 22:22:54 +0000 (22:22 +0000)
nicer to other VMs.

Thanks to Philip Jenvey for the pointer.

Lib/test/regrtest.py

index 8b46f6edfe0857f552db834d3bad55e5a0f18f62..b5a91efb92aa31c6d171cba6e7d52cba157221b1 100755 (executable)
@@ -152,6 +152,7 @@ example, to run all the tests except for the gui tests, give the
 option '-uall,-gui'.
 """
 
+import builtins
 import getopt
 import json
 import os
@@ -859,15 +860,9 @@ class saved_test_environment:
         sys.path_hooks[:] = saved_hooks[2]
 
     def get___import__(self):
-        if isinstance(__builtins__, dict):
-            return __builtins__['__import__']
-        else:
-            return __builtins__.__import__
+        return builtins.__import__
     def restore___import__(self, import_):
-        if isinstance(__builtins__, dict):
-            __builtins__['__import__'] = import_
-        else:
-            __builtins__.__import__ = import_
+        builtins.__import__ = import_
 
     def get_warnings_filters(self):
         return id(warnings.filters), warnings.filters, warnings.filters[:]