From b75310db3b11b777ace2fff117539ab4e8052809 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Mon, 5 May 2025 07:54:19 -0700 Subject: [PATCH] [3.13] gh-131878: Handle top level exceptions in new pyrepl and prevent of closing it (GH-131910) (cherry picked from commit 99a0d7e5b3c6e80f5b9b0ec88ae439d6d620253c) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sergey Miryanov Co-authored-by: Ɓukasz Langa --- Lib/_pyrepl/simple_interact.py | 5 +++++ .../2025-03-30-19-58-14.gh-issue-131878.uxM26H.rst | 1 + 2 files changed, 6 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2025-03-30-19-58-14.gh-issue-131878.uxM26H.rst diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index c6f40abfab4226..8148b19a942eb7 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -163,3 +163,8 @@ def maybe_run_command(statement: str) -> bool: except MemoryError: console.write("\nMemoryError\n") console.resetbuffer() + except SystemExit: + raise + except: + console.showtraceback() + console.resetbuffer() diff --git a/Misc/NEWS.d/next/Core and Builtins/2025-03-30-19-58-14.gh-issue-131878.uxM26H.rst b/Misc/NEWS.d/next/Core and Builtins/2025-03-30-19-58-14.gh-issue-131878.uxM26H.rst new file mode 100644 index 00000000000000..79b23db6d0b79e --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2025-03-30-19-58-14.gh-issue-131878.uxM26H.rst @@ -0,0 +1 @@ +Handle uncaught exceptions in the main input loop for the new REPL.