summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-11-11 16:28:30 (GMT)
committerGitHub <noreply@github.com>2024-11-11 16:28:30 (GMT)
commit79805d228440814c0674ab5190ef17f235503d2e (patch)
tree8cb9b29278e2638af831f543b6ccbe98fbd43362 /Lib/argparse.py
parent819830f34a11ecaa3aada174ca8eedeb3f260630 (diff)
downloadcpython-79805d228440814c0674ab5190ef17f235503d2e.zip
cpython-79805d228440814c0674ab5190ef17f235503d2e.tar.gz
cpython-79805d228440814c0674ab5190ef17f235503d2e.tar.bz2
gh-117941: Reject option names starting with "--no-" in argparse.BooleanOptionalAction (GH-125894)
They never worked correctly.
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 072cd5e..5ecfdca 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -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)