Commit 4507190a authored by Brett Cannon's avatar Brett Cannon

Switch the __import__ state check from using __builtins__ to builtins to be

nicer to other VMs.

Thanks to Philip Jenvey for the pointer.
parent 97958cf3
...@@ -152,6 +152,7 @@ example, to run all the tests except for the gui tests, give the ...@@ -152,6 +152,7 @@ example, to run all the tests except for the gui tests, give the
option '-uall,-gui'. option '-uall,-gui'.
""" """
import builtins
import getopt import getopt
import json import json
import os import os
...@@ -859,15 +860,9 @@ class saved_test_environment: ...@@ -859,15 +860,9 @@ class saved_test_environment:
sys.path_hooks[:] = saved_hooks[2] sys.path_hooks[:] = saved_hooks[2]
def get___import__(self): def get___import__(self):
if isinstance(__builtins__, dict): return builtins.__import__
return __builtins__['__import__']
else:
return __builtins__.__import__
def restore___import__(self, import_): def restore___import__(self, import_):
if isinstance(__builtins__, dict): builtins.__import__ = import_
__builtins__['__import__'] = import_
else:
__builtins__.__import__ = import_
def get_warnings_filters(self): def get_warnings_filters(self):
return id(warnings.filters), warnings.filters, warnings.filters[:] return id(warnings.filters), warnings.filters, warnings.filters[:]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment