Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-43316: gzip: CLI uses non-zero return code on error.#24647

Merged
methane merged 2 commits into
python:masterpython/cpython:masterfrom
rhpvorderman:bpo-43316rhpvorderman/cpython:bpo-43316Copy head branch name to clipboard
Feb 25, 2021
Merged

bpo-43316: gzip: CLI uses non-zero return code on error.#24647
methane merged 2 commits into
python:masterpython/cpython:masterfrom
rhpvorderman:bpo-43316rhpvorderman/cpython:bpo-43316Copy head branch name to clipboard

Conversation

@rhpvorderman

@rhpvorderman rhpvorderman commented Feb 25, 2021

Copy link
Copy Markdown
Contributor

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

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.
@methane methane added needs backport to 3.8 type-bug An unexpected behavior, bug, or error labels Feb 25, 2021
@methane methane changed the title bpo-43316: @rhpvorderman Handle failure due to extension properly in gzip CLI bpo-43316: gzip: CLI returns 1 and print error message to stderr. Feb 25, 2021
@methane methane changed the title bpo-43316: gzip: CLI returns 1 and print error message to stderr. bpo-43316: gzip: CLI returns 1 on error. Feb 25, 2021
@methane methane changed the title bpo-43316: gzip: CLI returns 1 on error. bpo-43316: gzip: CLI uses non-zero return code on error. Feb 25, 2021
@methane methane merged commit cc3df63 into python:master Feb 25, 2021
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @rhpvorderman for the PR, and @methane for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2021
)

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

Copy link
Copy Markdown

GH-24648 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2021
)

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

Copy link
Copy Markdown

GH-24649 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Feb 25, 2021
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

Copy link
Copy Markdown
Contributor Author

Thanks @methane !

Comment thread Lib/gzip.py
if arg[-3:] != ".gz":
print("filename doesn't end in .gz:", repr(arg))
continue
sys.exit("filename doesn't end in .gz:", repr(arg))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t this use string concatenation or f-string to pass one argument to sys.exit?

Signature is sys.exit(status=None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! We can not pass two strings to sys.exit().
I don't know why this passed the test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #24652

methane pushed a commit that referenced this pull request Feb 26, 2021
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>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.