Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4507190

Browse files
committed
Switch the __import__ state check from using __builtins__ to builtins to be
nicer to other VMs. Thanks to Philip Jenvey for the pointer.
1 parent 97958cf commit 4507190

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

Lib/test/regrtest.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
option '-uall,-gui'.
153153
"""
154154

155+
import builtins
155156
import getopt
156157
import json
157158
import os
@@ -859,15 +860,9 @@ def restore_sys_path_hooks(self, saved_hooks):
859860
sys.path_hooks[:] = saved_hooks[2]
860861

861862
def get___import__(self):
862-
if isinstance(__builtins__, dict):
863-
return __builtins__['__import__']
864-
else:
865-
return __builtins__.__import__
863+
return builtins.__import__
866864
def restore___import__(self, import_):
867-
if isinstance(__builtins__, dict):
868-
__builtins__['__import__'] = import_
869-
else:
870-
__builtins__.__import__ = import_
865+
builtins.__import__ = import_
871866

872867
def get_warnings_filters(self):
873868
return id(warnings.filters), warnings.filters, warnings.filters[:]

0 commit comments

Comments
 (0)