From a6864109db645045790d97b2e2b471d24a9a0560 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Wed, 5 Nov 2025 16:35:41 +1100 Subject: [PATCH] shared/runtime/pyexec: Set PYEXEC_FORCED_EXIT flag for SystemExit. When `MICROPY_PYEXEC_ENABLE_EXIT_CODE_HANDLING` is enabled, `SystemExit` now sets the `PYEXEC_FORCED_EXIT` flag in addition to the exit code. This allows the REPL to properly detect and exit when SystemExit is raised, while still preserving the exit code in the lower bits. Fixes `repl_lock.py` test which expects REPL to exit on `SystemExit`. Signed-off-by: Andrew Leech --- shared/runtime/pyexec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c index 428cc95b23..867bf58ab6 100644 --- a/shared/runtime/pyexec.c +++ b/shared/runtime/pyexec.c @@ -178,6 +178,8 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input } else { ret = PYEXEC_NORMAL_EXIT; } + // Set PYEXEC_FORCED_EXIT flag so REPL knows to exit + ret |= PYEXEC_FORCED_EXIT; #else ret = PYEXEC_FORCED_EXIT; #endif