From 223bb81887e801c5add67731bcb0e7107236f5d3 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Sun, 24 Mar 2024 17:40:42 +0100 Subject: [PATCH] Fix system exit hang on Python 3.8 --- src/exceptiongroup/_catch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/exceptiongroup/_catch.py b/src/exceptiongroup/_catch.py index 0246568..2b69282 100644 --- a/src/exceptiongroup/_catch.py +++ b/src/exceptiongroup/_catch.py @@ -36,6 +36,8 @@ def __exit__( else: if isinstance(exc, BaseExceptionGroup): try: + if isinstance(unhandled, SystemExit): + sys.exit(unhandled.code) raise unhandled from exc.__cause__ except BaseExceptionGroup: # Change __context__ to __cause__ because Python 3.11 does this