Message241967
| Author |
eryksun |
| Recipients |
belopolsky, eryksun, ethan.furman, skrah |
| Date |
2015年04月24日.18:18:52 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1429899532.99.0.746137622545.issue24052@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> --> import sys
> --> sys.exit(2**63)
> 9223372036854775808
The above is only Python 2.x behavior. On Windows, sys.maxint is 2147483647 (even for 64-bit Windows), so 2**63 is a Python long. Thus handle_system_exit takes the PyFile_WriteObject branch, with the actual exit code set to 1.
>>> import sys
>>> sys.exit(2**63)
9223372036854775808
C:\>echo %errorlevel%
1
In Python 3, PyLong_AsLong overflows for any value bigger than LONG_MAX, which sets the result to -1, i.e. 32-bit 0xFFFFFFFF, with overflow set. handle_system_exit ignores the overflow exception, so any exit code larger than 0x7FFFFFFF (2**31-1) is returned as 0xFFFFFFFF (2**32-1).
>>> cmd = '%s -c "import sys;sys.exit(%%d)"' % sys.executable
>>> subprocess.call(cmd % (2**31-1))
2147483647
>>> subprocess.call(cmd % (2**31))
4294967295
>>> subprocess.call(cmd % (2**63))
4294967295 |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年04月24日 18:18:53 | eryksun | set | recipients:
+ eryksun, belopolsky, skrah, ethan.furman |
| 2015年04月24日 18:18:52 | eryksun | set | messageid: <1429899532.99.0.746137622545.issue24052@psf.upfronthosting.co.za> |
| 2015年04月24日 18:18:52 | eryksun | link | issue24052 messages |
| 2015年04月24日 18:18:52 | eryksun | create |
|