This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gdr@garethrees.org
Recipients gdr@garethrees.org
Date 2012-03-21.00:07:59
SpamBayes Score 7.9414064e-10
Marked as misclassified No
Message-id <1332288480.19.0.200013792885.issue14376@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation for sys.exit says, "The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object".

However, the arguments that are treated as exit statuses are actually "subtypes of int".

So, a bool argument is fine:

    $ python2.7 -c "import sys; sys.exit(False)"; echo $?
    0

But a long argument is not:

    $ python2.7 -c "import sys; sys.exit(long(0))"; echo $?
    0
    1

The latter behaviour can be surprising since functions like os.spawnv may return the exit status of the executed process as a long on some platforms, so that if you try to pass on the exit code via

    code = os.spawnv(...)
    sys.exit(code)

you may get a mysterious surprise: code is 0 but exit code is 1.

It would be simple to change line 1112 of pythonrun.c from

    if (PyInt_Check(value))

to

    if (PyInt_Check(value) || PyLong_Check(value))

(This issue is not present in Python 3 because there is no longer a distinction between int and long.)
History
Date User Action Args
2012-03-21 00:08:00gdr@garethrees.orgsetrecipients: + gdr@garethrees.org
2012-03-21 00:08:00gdr@garethrees.orgsetmessageid: <1332288480.19.0.200013792885.issue14376@psf.upfronthosting.co.za>
2012-03-21 00:07:59gdr@garethrees.orglinkissue14376 messages
2012-03-21 00:07:59gdr@garethrees.orgcreate