mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
[3.13] gh-63143: Fix parsing mutually exclusive arguments in argparse (GH-124307) (GH-124418)
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
63870162f4
commit
167d8d2f07
3 changed files with 120 additions and 9 deletions
|
|
@ -1977,9 +1977,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