Skip to content

bpo-46080: Fix crash when argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS and help specified #30111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2022

Conversation

felixfontein
Copy link
Contributor

@felixfontein felixfontein commented Dec 15, 2021

When argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS and help specified, help text composition currently crashes. This PR fixes that by also checking whether default is not SUPPRESS before appending %(default)s to help.

https://bugs.python.org/issue46080

… default=argparse.SUPPRESS and help specified.
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@felixfontein

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

Copy link
Contributor

@taleinat taleinat left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I suggest some minor changes to the NEWS entry.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@taleinat taleinat added type-bug An unexpected behavior, bug, or error awaiting merge and removed awaiting changes labels Jan 20, 2022
@taleinat taleinat added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Jan 20, 2022
@taleinat taleinat merged commit 9e87c0e into python:main Jan 20, 2022
@miss-islington
Copy link
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 20, 2022
…nGH-30111)

Fix an uncaught exception during help text generation when
argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS
and help is specified.
(cherry picked from commit 9e87c0e)

Co-authored-by: Felix Fontein <[email protected]>
@bedevere-bot
Copy link

GH-30730 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jan 20, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 20, 2022
…nGH-30111)

Fix an uncaught exception during help text generation when
argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS
and help is specified.
(cherry picked from commit 9e87c0e)

Co-authored-by: Felix Fontein <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Jan 20, 2022
@bedevere-bot
Copy link

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

miss-islington added a commit that referenced this pull request Jan 20, 2022
)

Fix an uncaught exception during help text generation when
argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS
and help is specified.
(cherry picked from commit 9e87c0e)

Co-authored-by: Felix Fontein <[email protected]>
miss-islington added a commit that referenced this pull request Jan 20, 2022
)

Fix an uncaught exception during help text generation when
argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS
and help is specified.
(cherry picked from commit 9e87c0e)

Co-authored-by: Felix Fontein <[email protected]>
@felixfontein felixfontein deleted the fix-argparse-crash branch January 21, 2022 04:55
@felixfontein
Copy link
Contributor Author

@taleinat thanks for reviewing and merging this!

hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…nGH-30111)

Fix an uncaught exception during help text generation when
argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS
and help is specified.
(cherry picked from commit 9e87c0e)

Co-authored-by: Felix Fontein <[email protected]>
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.

5 participants