mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-134970: Fix exception message in argparse module (GH-134971)
Fix the "unknown action" exception in argparse.ArgumentParser.add_argument_group() to correctly replace the action class.
This commit is contained in:
parent
cebae977a6
commit
965c480566
2 changed files with 4 additions and 1 deletions
|
@ -1534,7 +1534,7 @@ class _ActionsContainer(object):
|
||||||
action_name = kwargs.get('action')
|
action_name = kwargs.get('action')
|
||||||
action_class = self._pop_action_class(kwargs)
|
action_class = self._pop_action_class(kwargs)
|
||||||
if not callable(action_class):
|
if not callable(action_class):
|
||||||
raise ValueError('unknown action {action_class!r}')
|
raise ValueError(f'unknown action {action_class!r}')
|
||||||
action = action_class(**kwargs)
|
action = action_class(**kwargs)
|
||||||
|
|
||||||
# raise an error if action for positional argument does not
|
# raise an error if action for positional argument does not
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Fix the "unknown action" exception in
|
||||||
|
:meth:`argparse.ArgumentParser.add_argument_group` to correctly replace the
|
||||||
|
action class.
|
Loading…
Add table
Add a link
Reference in a new issue