Uh oh!
There was an error while loading. Please reload this page.
bpo-43316: gzip: CLI uses non-zero return code on error. - #24647
Conversation
Exit code is now 1 instead of 0. A message is printed to stderr instead of stdout. This is the proper behaviour for a tool that can be used in scripts.
miss-islington
commented
Feb 25, 2021
Thanks @rhpvorderman for the PR, and @methane for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
) Exit code is now 1 instead of 0. A message is printed to stderr instead of stdout. This is the proper behaviour for a tool that can be used in scripts. (cherry picked from commit cc3df63) Co-authored-by: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
bedevere-bot
commented
Feb 25, 2021
GH-24648 is a backport of this pull request to the 3.9 branch. |
) Exit code is now 1 instead of 0. A message is printed to stderr instead of stdout. This is the proper behaviour for a tool that can be used in scripts. (cherry picked from commit cc3df63) Co-authored-by: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
bedevere-bot
commented
Feb 25, 2021
GH-24649 is a backport of this pull request to the 3.8 branch. |
Exit code is now 1 instead of 0. A message is printed to stderr instead of stdout. This is the proper behaviour for a tool that can be used in scripts. (cherry picked from commit cc3df63) Co-authored-by: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
rhpvorderman
commented
Feb 25, 2021
Thanks @methane ! |
| if arg[-3:] != ".gz": | ||
| print("filename doesn't end in .gz:", repr(arg)) | ||
| continue | ||
| sys.exit("filename doesn't end in .gz:", repr(arg)) |
There was a problem hiding this comment.
Shouldn’t this use string concatenation or f-string to pass one argument to sys.exit?
Signature is sys.exit(status=None)
There was a problem hiding this comment.
You are right! We can not pass two strings to sys.exit().
I don't know why this passed the test.
There was a problem hiding this comment.
Now I got it. The stderr is:
Traceback (most recent call last):
(snip)
File "/Users/inada-n/work/python/cpython/Lib/gzip.py", line 586, in main
sys.exit("filename doesn't end in .gz:", repr(arg))
TypeError: exit expected at most 1 argument, got 2
And it passes the test self.assertIn(b"filename doesn't end in .gz:", err).
Exit code is now 1 instead of 0. A message is printed to stderr instead of stdout. This is the proper behaviour for a tool that can be used in scripts. (cherry picked from commit cc3df63) Co-authored-by: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
Exit code is now 1 instead of 0. A message is printed to stderr instead of stdout. This is
the proper behaviour for a tool that can be used in scripts.
In my opinion this change should be backported to all currently supported versions of python. Exiting with 0 upon error is not acceptable behaviour for a tool. Luckily, I think the backport will be quite easy and I am happy to do it.
https://bugs.python.org/issue43316