eryksun added the comment:

> --> 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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24052>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to