[issue36691] SystemExit & sys.exit : Allow both exit status and message

Serhiy Storchaka report at bugs.python.org
Sun Apr 21 11:19:45 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

The default handler writes the message of non-integer code to stderr, but in case of '--help', the message should be written to stdout. So this feature is not applicable for it. Are there other examples where this feature can be used?

In such cases it is better to write the message explicitly and call sys.exit() with the required exit code. For tests you can use contextlib.redirect_stderr() (or manually replace sys.stderr) to capture the stderr output.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36691>
_______________________________________


More information about the Python-bugs-list mailing list