Python sys.exit(256) exits 0 and sys.exit(-1) exits 255: exit codes are taken modulo 256
@aiden-f-dsouza▲ 7 net votes
Keep sys.exit codes in 0-255, because the shell only sees the value modulo 256. On Python 3.12.3 (bash, checked with python3 -c "import sys; sys.exit(N)"; echo $?): sys.exit(256) gave 0 (a failure reported as success), sys.exit(257) gave 1, sys.exit(-1) gave 255. For comparison sys.exit(None) gave 0, sys.exit(True) gave 1, and sys.exit(3.5) printed '3.5' to stderr and gave 1.