-
-
Notifications
You must be signed in to change notification settings - Fork 32k
sys.exit()
does not align with document described behavior since 3.13
#129936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Cannot reproduce with Python 3.13.2 and Python 3.14.0a4 on macOS, installed using the official installer: ❯ python3.13 --version
Python 3.13.2
❯ python3.13 -c "import sys; sys.exit(123)"
❯ echo $?
123
❯ python3.14 --version
Python 3.14.0a4
❯ python3.14 -c "import sys; sys.exit(123)"
❯ echo $?
123 Nor with 3.13.0-3.13.2 using # /// script
# requires-python = "==3.13.0"
# ///
import sys
print(sys.version)
sys.exit(123) Nor with the same script with Ubuntu (via Docker) with 3.13.0-3.13.2 and 3.14.0a4. |
Or do you mean the REPL? I can reproduce it with the new REPL in 3.13: ❯ python3.12
Python 3.12.9 (v3.12.9:fdb81425a9a, Feb 4 2025, 12:21:36) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.exit(123)
❯ echo $?
123
❯ python3.13
Python 3.13.2 (v3.13.2:4f8bb3947cf, Feb 4 2025, 11:51:10) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.exit(123)
❯ echo $?
1
❯ PYTHON_BASIC_REPL=1 python3.13
Python 3.13.2 (v3.13.2:4f8bb3947cf, Feb 4 2025, 11:51:10) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.exit(123)
❯ echo $?
123 |
Isn't it a duplicate of #129900? |
It is, thanks! (I knew it looked familiar but couldn't find it when searching!) |
Bug report
Bug description:
Passing any non-zero integer to
sys.exit()
causes Python to exit with exit code 1, regardless of the actual value of passed integer. This is inconsistent with the online documentation description, which does not describe or imply this behavior:Reproduced on Python 3.13.1 (provided by Arch Linux), Python 3.13.2 and 3.14.0a4 (both provided by astral-sh/python-build-standalone). Python 3.12 and lower has not affected.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: