@@ -288,10 +288,11 @@ def __init__(self, locals=None, encoding=sys.getdefaultencoding()):
288288 code .InteractiveInterpreter .__init__ (self , locals )
289289
290290 if not py3 :
291- def runsource (self , source ):
291+ def runsource (self , source , filename = '<input>' , symbol = 'single' ):
292292 source = '# coding: %s\n %s' % (self .encoding ,
293293 source .encode (self .encoding ))
294- return code .InteractiveInterpreter .runsource (self , source )
294+ return code .InteractiveInterpreter .runsource (self , source ,
295+ filename , symbol )
295296
296297 def showsyntaxerror (self , filename = None ):
297298 """Override the regular handler, the code's copied and pasted from
@@ -1201,10 +1202,8 @@ def repl(self):
12011202# feature so please notify me of any breakage.
12021203 filename = os .environ .get ('PYTHONSTARTUP' )
12031204 if filename and os .path .isfile (filename ):
1204- f = open (filename , 'r' )
1205- code_obj = compile (f .read (), filename , 'exec' )
1206- f .close ()
1207- self .interp .runcode (code_obj )
1205+ with open (filename , 'r' ) as f :
1206+ self .interp .runsource (f .read (), filename , 'exec' )
12081207
12091208# Use our own helper function because Python's will use real stdin and
12101209# stdout instead of our wrapped
0 commit comments