Skip to content

Commit c854026

Browse files
committed
refactor: replace magic number 120 with named constant EXITCODE_FLUSH_FAILURE
Address review feedback on PR #7503: improve readability by extracting the CPython-compat exit code into a named constant. Signed-off-by: majiayu000 <1835304752@qq.com>
1 parent 043d00f commit c854026

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/vm/src/vm/interpreter.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ use core::sync::atomic::Ordering;
1010

1111
type InitFunc = Box<dyn FnOnce(&mut VirtualMachine)>;
1212

13+
/// Exit code used when stdout/stderr flush fails during interpreter shutdown.
14+
/// Matches CPython's behavior (see cpython/Python/pylifecycle.c).
15+
const EXITCODE_FLUSH_FAILURE: u32 = 120;
16+
1317
/// Configuration builder for constructing an Interpreter.
1418
///
1519
/// This is the preferred way to configure and create an interpreter with custom modules.
@@ -445,7 +449,7 @@ impl Interpreter {
445449

446450
// Match CPython: if exit_code is 0 and stdout flush failed, exit 120
447451
if exit_code == 0 && flush_status < 0 {
448-
120
452+
EXITCODE_FLUSH_FAILURE
449453
} else {
450454
exit_code
451455
}

0 commit comments

Comments
 (0)