@@ -77,11 +77,6 @@ def __init__(
77
77
def showtraceback (self ):
78
78
super ().showtraceback (colorize = self .can_colorize )
79
79
80
- def push (self , line , filename = None , symbol = "single" ):
81
- if line .count ("\n " ) > 0 :
82
- symbol = "exec"
83
- return super ().push (line , filename = filename , _symbol = symbol )
84
-
85
80
86
81
def run_multiline_interactive_console (
87
82
mainmodule : ModuleType | None = None , future_flags : int = 0
@@ -140,7 +135,7 @@ def more_lines(unicodetext: str) -> bool:
140
135
ps1 = getattr (sys , "ps1" , ">>> " )
141
136
ps2 = getattr (sys , "ps2" , "... " )
142
137
try :
143
- statement = multiline_input (more_lines , ps1 , ps2 )
138
+ statement , contains_pasted_code = multiline_input (more_lines , ps1 , ps2 )
144
139
except EOFError :
145
140
break
146
141
@@ -149,7 +144,10 @@ def more_lines(unicodetext: str) -> bool:
149
144
150
145
input_name = f"<python-input-{ input_n } >"
151
146
linecache ._register_code (input_name , statement , "<stdin>" ) # type: ignore[attr-defined]
152
- more = console .push (_strip_final_indent (statement ), filename = input_name )
147
+ symbol = "single" if not contains_pasted_code else "exec"
148
+ more = console .push (_strip_final_indent (statement ), filename = input_name , _symbol = symbol )
149
+ if contains_pasted_code and more :
150
+ more = console .push (_strip_final_indent (statement ), filename = input_name , _symbol = "single" )
153
151
assert not more
154
152
input_n += 1
155
153
except KeyboardInterrupt :
0 commit comments