@@ -100,38 +100,6 @@ def readline(self):
100100 self .repl .send_to_stdout (value )
101101 return value
102102
103- def get_interpreter (config , locals_ = None ):
104- if config .scroll_auto_import and sys .version_info [0 ] == 3 and sys .version_info [1 ] >= 3 :
105-
106- default = {'__name__' : '__main__' ,
107- '__doc__' : None ,
108- '__cached__' : None ,
109- '__package__' : None ,}
110- locals_ = default if locals_ is None else locals_
111- autoimported = []
112-
113- class AutoImporter (dict ):
114- def __getitem__ (self , item ):
115- if dict .__contains__ (self , item ):
116- return dict .__getitem__ (self , item )
117- else :
118- try :
119- module = __import__ (item )
120- autoimported .append (item )
121- globals ()[item ] = module
122- return module
123- except ImportError :
124- raise KeyError (item )
125- @property
126- def autoimported (self ):
127- return autoimported
128-
129- ns = AutoImporter ()
130- ns .update (locals_ )
131- return code .InteractiveInterpreter (locals = ns )
132- else :
133- return code .InteractiveInterpreter (locals = locals_ )
134-
135103class Repl (BpythonRepl ):
136104 """
137105
@@ -158,7 +126,7 @@ def __init__(self, locals_=None, config=None, stuff_a_refresh_request=lambda: No
158126 config = Struct ()
159127 loadini (config , default_config_path ())
160128
161- interp = get_interpreter ( config , locals_ = locals_ )
129+ interp = code . InteractiveInterpreter ( locals = locals_ )
162130
163131 if banner is None :
164132 banner = _ ('welcome to bpython' )
@@ -830,7 +798,7 @@ def reevaluate(self, insert_into_history=False):
830798 self .display_lines = []
831799
832800 self .done = True # this keeps the first prompt correct
833- self .interp = get_interpreter ( self . config )
801+ self .interp = code . InteractiveInterpreter ( )
834802 self .coderunner .interp = self .interp
835803 self .completer = Autocomplete (self .interp .locals , self .config )
836804 self .completer .autocomplete_mode = 'simple'
@@ -854,9 +822,7 @@ def reevaluate(self, insert_into_history=False):
854822
855823 def getstdout (self ):
856824 lines = self .lines_for_display + [self .current_line_formatted ]
857- imports = (['%simport %s' % (self .ps1 , name ) for name in self .interp .locals .autoimported ]
858- if hasattr (self .interp .locals , 'autoimported' ) else [])
859- s = '\n ' .join (imports + [x .s if isinstance (x , FmtStr ) else x for x in lines ]
825+ s = '\n ' .join ([x .s if isinstance (x , FmtStr ) else x for x in lines ]
860826 ) if lines else ''
861827 return s
862828 def send_to_external_editor (self , filename = None ):
0 commit comments