diff --git a/Lib/test/test_pyrepl/test_interact.py b/Lib/test/test_pyrepl/test_interact.py index c3204832a6a93a..af5d4d0e67632a 100644 --- a/Lib/test/test_pyrepl/test_interact.py +++ b/Lib/test/test_pyrepl/test_interact.py @@ -58,7 +58,7 @@ def test_multiple_statements_fail_early(self): console = InteractiveColoredConsole() code = dedent("""\ raise Exception('foobar') - print('spam&eggs') + print('spam', 'eggs', sep='&') """) f = io.StringIO() with contextlib.redirect_stderr(f): diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py index 228b326699e75f..304256ee65fb82 100644 --- a/Lib/test/test_repl.py +++ b/Lib/test/test_repl.py @@ -296,12 +296,12 @@ def f(): class TestAsyncioREPL(unittest.TestCase): def test_multiple_statements_fail_early(self): - user_input = "1 / 0; print(f'afterwards: {1+1}')" + user_input = "1 / 0; print('after' + 'wards')" p = spawn_repl("-m", "asyncio") p.stdin.write(user_input) output = kill_python(p) self.assertIn("ZeroDivisionError", output) - self.assertNotIn("afterwards: 2", output) + self.assertNotIn("afterwards", output) def test_toplevel_contextvars_sync(self): user_input = dedent("""\ diff --git a/Misc/NEWS.d/next/Library/2025-01-30-22-49-42.gh-issue-128231.SuEC18.rst b/Misc/NEWS.d/next/Library/2025-01-30-22-49-42.gh-issue-128231.SuEC18.rst new file mode 100644 index 00000000000000..a70b6a1fc14d63 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-01-30-22-49-42.gh-issue-128231.SuEC18.rst @@ -0,0 +1,2 @@ +Execution of multiple statements in the new REPL now stops immediately upon +the first exception encountered. Patch by Bartosz Sławecki.