1515import threading
1616import time
1717import unicodedata
18- from six .moves import range
18+ from six .moves import range , builtins
1919
2020from pygments import format
2121from bpython ._py3compat import PythonLexer
@@ -416,7 +416,7 @@ def __enter__(self):
416416 signal .signal (signal .SIGWINCH , self .sigwinch_handler )
417417 signal .signal (signal .SIGTSTP , self .sigtstp_handler )
418418
419- self .orig_import = __builtins__ [ ' __import__' ]
419+ self .orig_import = builtins . __import__
420420 if self .watcher :
421421 # for reading modules if they fail to load
422422 old_module_locations = {}
@@ -438,7 +438,7 @@ def new_import(name, globals={}, locals={}, fromlist=[],
438438 old_module_locations [name ] = m .__file__
439439 self .watcher .track_module (m .__file__ )
440440 return m
441- __builtins__ [ ' __import__' ] = new_import
441+ builtins . __import__ = new_import
442442
443443 sitefix .monkeypatch_quit ()
444444 return self
@@ -449,7 +449,7 @@ def __exit__(self, *args):
449449 sys .stderr = self .orig_stderr
450450 signal .signal (signal .SIGWINCH , self .orig_sigwinch_handler )
451451 signal .signal (signal .SIGTSTP , self .orig_sigtstp_handler )
452- __builtins__ [ ' __import__' ] = self .orig_import
452+ builtins . __import__ = self .orig_import
453453
454454 def sigwinch_handler (self , signum , frame ):
455455 old_rows , old_columns = self .height , self .width
0 commit comments