Commit e1ecb87
authored
fix: Flush stdout on shutdown matching CPython behavior (#7503)
* fix: flush stdout on interpreter shutdown matching CPython behavior
When stdout flush fails during shutdown, report the error via
run_unraisable and exit with code 120 (matching CPython's
Py_FinalizeEx). Skip flushing already-closed or None streams.
Stderr flush errors remain silently ignored per CPython behavior.
Fixes #5521
Signed-off-by: majiayu000 <1835304752@qq.com>
* 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>
---------
Signed-off-by: majiayu000 <1835304752@qq.com>1 parent ea5a6cd commit e1ecb87
File tree
3 files changed
+35
-9
lines changed- Lib/test
- crates/vm/src/vm
3 files changed
+35
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
479 | | - | |
480 | 478 | | |
481 | 479 | | |
482 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| |||
401 | 405 | | |
402 | 406 | | |
403 | 407 | | |
404 | | - | |
| 408 | + | |
405 | 409 | | |
406 | 410 | | |
407 | 411 | | |
| |||
439 | 443 | | |
440 | 444 | | |
441 | 445 | | |
442 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
443 | 449 | | |
444 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
445 | 456 | | |
446 | 457 | | |
447 | 458 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
56 | 63 | | |
57 | | - | |
58 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
59 | 72 | | |
60 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
61 | 77 | | |
62 | 78 | | |
| 79 | + | |
63 | 80 | | |
64 | 81 | | |
65 | 82 | | |
| |||
0 commit comments