]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-125842: Fix `sys.exit(0xffff_ffff)` on Windows (GH-125896) (GH-125925)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 24 Oct 2024 16:27:30 +0000 (18:27 +0200)
committerGitHub <noreply@github.com>
Thu, 24 Oct 2024 16:27:30 +0000 (16:27 +0000)
commit52b57eee64c1fe98306fae9643f7c8b66548fab0
tree4093685486b127193a8da622014213a23ff46331
parent5c2696bc261905b84c71ddbee3f439af568a8795
[3.13] gh-125842: Fix `sys.exit(0xffff_ffff)` on Windows (GH-125896) (GH-125925)

On Windows, `long` is a signed 32-bit integer so it can't represent
`0xffff_ffff` without overflow. Windows exit codes are unsigned 32-bit
integers, so if a child process exits with `-1`, it will be represented
as `0xffff_ffff`.

Also fix a number of other possible cases where `_Py_HandleSystemExit`
could return with an exception set, leading to a `SystemError` (or
fatal error in debug builds) later on during shutdown.
(cherry picked from commit ad6110a93ffa82cae71af6c78692de065d3871b5)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Lib/test/test_sys.py
Misc/NEWS.d/next/Windows/2024-10-23-17-24-23.gh-issue-125842.m3EF9E.rst [new file with mode: 0644]
Python/pythonrun.c