mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-117941: Reject option names starting with "--no-" in argparse.BooleanOptionalAction (GH-125894)
They never worked correctly.
This commit is contained in:
parent
819830f34a
commit
79805d2284
3 changed files with 12 additions and 0 deletions
|
@ -863,6 +863,9 @@ class BooleanOptionalAction(Action):
|
|||
_option_strings.append(option_string)
|
||||
|
||||
if option_string.startswith('--'):
|
||||
if option_string.startswith('--no-'):
|
||||
raise ValueError(f'invalid option name {option_string!r} '
|
||||
f'for BooleanOptionalAction')
|
||||
option_string = '--no-' + option_string[2:]
|
||||
_option_strings.append(option_string)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue