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.

classification
Title: sys.exit with bool parameter
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Polux.Moon, docs@python, eric.smith, r.david.murray, rhettinger
Priority: normal Keywords:

Created on 2014-12-18 15:06 by Polux.Moon, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg232883 - (view) Author: Polux Moon (Polux.Moon) Date: 2014-12-18 15:06
when using a bool as parameter implementation (2.7) behave like:
sys.exit(True) <=> sys.exit(1)
sys.exit(False) <=> sys.exit(0)

so the bool indicate if the termination is abnormal

following the doc it should be equivalent to sys.exit(1) in all cases
if we assume the implementation is right, the doc should describe the behavior for boolean input
msg232884 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-12-18 15:15
>>> issubclass(bool, int)
True
>>> True == 1
True
[41846 refs]
>>> False == 0
True

This is fundamental to Python, so it is not obvious that it is a good idea to mention bool explicitly in the sys.exit docs.  Perhaps we could change it to say "int (or an int subclass such as bool)".
msg232885 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2014-12-18 15:17
I'm not sure this should be documented. It follows from int and bool equivalence. Plus, I consider it an anti-pattern.

We don't want to document everywhere you can pass a bool where an int is called for. That's thousands of places.
msg232886 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-12-18 15:20
Hmm.  Good point about the anti-pattern.  I agree that it is probably best to leave the docs as they are.
msg232888 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-12-18 15:58
I agree that the docs are best as-is.
History
Date User Action Args
2022-04-11 14:58:11adminsetgithub: 67272
2014-12-18 17:45:15eric.smithsetstage: resolved
2014-12-18 15:58:46rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg232888

resolution: rejected
2014-12-18 15:20:44r.david.murraysetmessages: + msg232886
2014-12-18 15:17:02eric.smithsetnosy: + eric.smith
messages: + msg232885
2014-12-18 15:15:53r.david.murraysetnosy: + r.david.murray

messages: + msg232884
versions: - Python 3.2, Python 3.3, Python 3.6
2014-12-18 15:06:24Polux.Mooncreate