8000 Revert "[3.13] gh-128231: Use `runcode()` return value for failing ea… · hugovk/cpython@f32bd0a · GitHub
[go: up one dir, main page]

Skip to content

Commit f32bd0a

Browse files
committed
Revert "[3.13] pythongh-128231: Use runcode() return value for failing early (pythonGH-129488) (python#130513)"
This reverts commit 8f6a9aa.
1 parent 7f7fc54 commit f32bd0a

File tree

5 files changed

+3
-40
lines changed

5 files changed

+3
-40
lines changed

Lib/_pyrepl/console.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ def repaint(self) -> None: ...
153153

154154

155155
class InteractiveColoredConsole(code.InteractiveConsole):
156-
STATEMENT_FAILED = object()
157-
158156
def __init__(
159157
self,
160158
locals: dict[str, object] | None = None,
@@ -176,16 +174,6 @@ def _excepthook(self, typ, value, tb):
176174
limit=traceback.BUILTIN_EXCEPTION_LIMIT)
177175
self.write(''.join(lines))
178176

179-
def runcode(self, code):
180-
try:
181-
exec(code, self.locals)
182-
except SystemExit:
183-
raise
184-
except BaseException:
185-
self.showtraceback()
186-
return self.STATEMENT_FAILED
187-
return None
188-
189177
def runsource(self, source, filename="<input>", symbol="single"):
190178
try:
191179
tree = self.compile.compiler(
@@ -223,7 +211,5 @@ def runsource(self, source, filename="<input>", symbol="single"):
223211
if code is None:
224212
return True
225213

226-
result = self.runcode(code)
227-
if result is self.STATEMENT_FAILED:
228-
break
214+
self.runcode(code)
229215
return False

Lib/asyncio/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def callback():
7575
self.write("\nKeyboardInterrupt\n")
7676
else:
7777
self.showtraceback()
8000
78-
return self.STATEMENT_FAILED
78+
7979

8080
class REPLThread(threading.Thread):
8181

Lib/test/test_pyrepl/test_interact.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ def test_multiple_statements_output(self):
5353
self.assertFalse(more)
5454
self.assertEqual(f.getvalue(), "1\n")
5555

56-
@force_not_colorized
57-
def test_multiple_statements_fail_early(self):
58-
console = InteractiveColoredConsole()
59-
code = dedent("""\
60-
raise Exception('foobar')
61-
print('spam&eggs')
62-
""")
63-
f = io.StringIO()
64-
with contextlib.redirect_stderr(f):
65-
console.runsource(code)
66-
self.assertIn('Exception: foobar', f.getvalue())
67-
self.assertNotIn('spam&eggs', f.getvalue())
68-
6956
def test_empty(self):
7057
namespace = {}
7158
code = ""

Lib/test/test_repl.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,7 @@ def f():
294294
self.assertEqual(traceback_lines, expected_lines)
295295

296296

297-
class TestAsyncioREPL(unittest.TestCase):
298-
def test_multiple_statements_fail_early(self):
299-
user_input = "1 / 0; print('afterwards')"
300-
p = spawn_repl("-m", "asyncio")
301-
p.stdin.write(user_input)
302-
output = kill_python(p)
303-
self.assertIn("ZeroDivisionError", output)
304-
self.assertNotIn("afterwards", output)
305-
297+
class TestAsyncioREPLContextVars(unittest.TestCase):
306298
def test_toplevel_contextvars_sync(self):
307299
user_input = dedent("""\
308300
from contextvars import ContextVar

Misc/NEWS.d/next/Library/2025-01-30-22-49-42.gh-issue-128231.SuEC18.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0