mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-63143: Fix parsing mutually exclusive arguments in argparse (GH-124307)
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".
This commit is contained in:
parent
faef3fa653
commit
3094cd17b0
3 changed files with 120 additions and 9 deletions
|
|
@ -1949,9 +1949,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