@@ -110,9 +110,8 @@ class Interpreter(code.InteractiveInterpreter):
110110
111111 def __init__ (
112112 self ,
113- locals : Optional [MutableMapping [str , str ]] = None ,
114- encoding : Optional [str ] = None ,
115- ):
113+ locals : Optional [MutableMapping [str , Any ]] = None ,
114+ ) -> None :
116115 """Constructor.
117116
118117 The optional 'locals' argument specifies the dictionary in which code
@@ -126,14 +125,8 @@ def __init__(
126125 callback can be added to the Interpreter instance afterwards - more
127126 specifically, this is so that autoindentation does not occur after a
128127 traceback.
129-
130- encoding is only used in Python 2, where it may be necessary to add an
131- encoding comment to a source bytestring before running it.
132- encoding must be a bytestring in Python 2 because it will be templated
133- into a bytestring source as part of an encoding comment.
134128 """
135129
136- self .encoding = encoding or getpreferredencoding ()
137130 self .syntaxerror_callback : Optional [Callable ] = None
138131
139132 if locals is None :
@@ -145,36 +138,21 @@ def __init__(
145138 super ().__init__ (locals )
146139 self .timer = RuntimeTimer ()
147140
148- def runsource (self , source , filename = None , symbol = "single" , encode = "auto" ):
141+ def runsource (
142+ self ,
143+ source : str ,
144+ filename : Optional [str ] = None ,
145+ symbol : str = "single" ,
146+ ) -> bool :
149147 """Execute Python code.
150148
151149 source, filename and symbol are passed on to
152- code.InteractiveInterpreter.runsource. If encode is True,
153- an encoding comment will be added to the source.
154- On Python 3.X, encode will be ignored.
155-
156- encode should only be used for interactive interpreter input,
157- files should always already have an encoding comment or be ASCII.
158- By default an encoding line will be added if no filename is given.
159-
160- source must be a string
161-
162- Because adding an encoding comment to a unicode string in Python 2
163- would cause a syntax error to be thrown which would reference code
164- the user did not write, setting encoding to True when source is a
165- unicode string in Python 2 will throw a ValueError."""
166- if encode and filename is not None :
167- # files have encoding comments or implicit encoding of ASCII
168- if encode != "auto" :
169- raise ValueError ("shouldn't add encoding line to file contents" )
170- encode = False
150+ code.InteractiveInterpreter.runsource."""
171151
172152 if filename is None :
173153 filename = filename_for_console_input (source )
174154 with self .timer :
175- return code .InteractiveInterpreter .runsource (
176- self , source , filename , symbol
177- )
155+ return super ().runsource (source , filename , symbol )
178156
179157 def showsyntaxerror (self , filename = None ):
180158 """Override the regular handler, the code's copied and pasted from
@@ -532,7 +510,7 @@ def startup(self) -> None:
532510 encoding = inspection .get_encoding_file (filename )
533511 with open (filename , encoding = encoding ) as f :
534512 source = f .read ()
535- self .interp .runsource (source , filename , "exec" , encode = False )
513+ self .interp .runsource (source , filename , "exec" )
536514
537515 def current_string (self , concatenate = False ):
538516 """If the line ends in a string get it, otherwise return ''"""
0 commit comments