GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-43316: gzip: CLI uses non-zero return code on error. by rhpvorderman · Pull Request #24647 · python/cpython

Conversation

@rhpvorderman

@rhpvorderman rhpvorderman commented Feb 25, 2021 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
rhpvorderman added 2 commits February 25, 2021 09:42
@rhpvorderman
Handle failure due to extension properly in gzip CLI
b6f7ccc
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.
@rhpvorderman
Add news entry for bpo-43316
17544da
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 25, 2021
@bedevere-bot bedevere-bot added the awaiting review label Feb 25, 2021
@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

miss-islington commented Feb 25, 2021

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.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting review label Feb 25, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2021
@rhpvorderman @miss-islington
bpo-43316: gzip: CLI uses non-zero return code on error. (pythonGH-24647
89024f3
)

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 <[email protected]>
@bedevere-bot

bedevere-bot commented Feb 25, 2021

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 label Feb 25, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2021
@rhpvorderman @miss-islington
bpo-43316: gzip: CLI uses non-zero return code on error. (pythonGH-24647
8139730
)

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 <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.8 label Feb 25, 2021
@bedevere-bot

bedevere-bot commented Feb 25, 2021

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington added a commit that referenced this pull request Feb 25, 2021
@miss-islington @rhpvorderman
bpo-43316: gzip: CLI uses non-zero return code on error. (GH-24647)
69906c5
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 <[email protected]>
@rhpvorderman

rhpvorderman commented Feb 25, 2021

Copy link
Copy Markdown
Contributor Author

Thanks @methane !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

merwok
merwok reviewed Feb 25, 2021
View reviewed changes
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))

@merwok merwok Feb 25, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 26, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 26, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 26, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed in #24652

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
methane pushed a commit that referenced this pull request Feb 26, 2021
@miss-islington @rhpvorderman
bpo-43316: gzip: CLI uses non-zero return code on error. (GH-24647)
adea9b8
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 <[email protected]>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
@rhpvorderman @adorilson
bpo-43316: gzip: CLI uses non-zero return code on error. (pythonGH-24647
6b5c8e4
)

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.
@rhpvorderman rhpvorderman mentioned this pull request Oct 17, 2022
Give python-isal a mention in the zlib/gzip documentation #98347
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@methane methane methane left review comments
@merwok merwok merwok left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@rhpvorderman @miss-islington @bedevere-bot @methane @merwok @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.