Skip to content

Commit 965c480

Browse files
authored
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.
1 parent cebae97 commit 965c480

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/argparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ def add_argument(self, *args, **kwargs):
15341534
action_name = kwargs.get('action')
15351535
action_class = self._pop_action_class(kwargs)
15361536
if not callable(action_class):
1537-
raise ValueError('unknown action {action_class!r}')
1537+
raise ValueError(f'unknown action {action_class!r}')
15381538
action = action_class(**kwargs)
15391539

15401540
# raise an error if action for positional argument does not
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix the "unknown action" exception in
2+
:meth:`argparse.ArgumentParser.add_argument_group` to correctly replace the
3+
action class.

0 commit comments

Comments
 (0)