Skip to content

gh-92445 Fix incorrect interaction between nargs="*" and choices() #92565

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 7 commits into from
Aug 25, 2022

Conversation

Harry-Lees
Copy link
Contributor

gh-92445: Fixed issue where using nargs="*" with choices caused an error to be incorrectly raised.

The example

from argparse import ArgumentParser

p = ArgumentParser()
p.add_argument('dessert', nargs='*', choices=('cake', 'pie'))
p.parse_args([])

now returns

Namespace(dessert=[])

@rhettinger
Copy link
Contributor

Please add a NEWS entry.

@rhettinger rhettinger changed the title gh-92445 Fix nargs="*" gh-92445 Fix incorrect interaction between nargs="*" and choices() May 9, 2022
@rhettinger rhettinger self-assigned this May 9, 2022
@rhettinger rhettinger added 3.11 only security fixes 3.10 only security fixes 3.12 only security fixes labels May 9, 2022
@rhettinger rhettinger merged commit ad7340e into python:main Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants