mirror of
https://github.com/python/cpython.git
synced 2025-08-08 02:48:55 +00:00
[3.12] gh-63143: Fix parsing mutually exclusive arguments in argparse (GH-124307) (GH-124419)
Arguments with the value identical to the default value (e.g. booleans,
small integers, empty or 1-character strings) are no longer considered
"not present".
(cherry picked from commit 3094cd17b0
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
1366fff609
commit
e57fbe3d2d
3 changed files with 120 additions and 9 deletions
|
@ -1991,9 +1991,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
argument_values = self._get_values(action, argument_strings)
|
||||
|
||||
# error if this argument is not allowed with other previously
|
||||
# seen arguments, assuming that actions that use the default
|
||||
# value don't really count as "present"
|
||||
if argument_values is not action.default:
|
||||
# seen arguments
|
||||
if action.option_strings or argument_strings:
|
||||
seen_non_default_actions.add(action)
|
||||
for conflict_action in action_conflicts.get(action, []):
|
||||
if conflict_action in seen_non_default_actions:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue