]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-134970: Fix exception message in argparse module (GH-134971) (GH-134991)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 1 Jun 2025 06:21:34 +0000 (08:21 +0200)
committerGitHub <noreply@github.com>
Sun, 1 Jun 2025 06:21:34 +0000 (06:21 +0000)
Fix the "unknown action" exception in argparse.ArgumentParser.add_argument_group()
to correctly replace the action class.
(cherry picked from commit 965c48056633d3f4b41520c8cd07f0275f00fb4c)

Co-authored-by: Michał Górny <mgorny@gentoo.org>
Lib/argparse.py
Misc/NEWS.d/next/Library/2025-05-31-12-08-12.gh-issue-134970.lgSaxq.rst [new file with mode: 0644]

index d1a6350c3fda6d324c826192672e3df3ff877f8e..83258cf3e0f37d0e0b3e4a6d0cadf021199d705d 100644 (file)
@@ -1534,7 +1534,7 @@ class _ActionsContainer(object):
         action_name = kwargs.get('action')
         action_class = self._pop_action_class(kwargs)
         if not callable(action_class):
-            raise ValueError('unknown action {action_class!r}')
+            raise ValueError(f'unknown action {action_class!r}')
         action = action_class(**kwargs)
 
         # raise an error if action for positional argument does not
diff --git a/Misc/NEWS.d/next/Library/2025-05-31-12-08-12.gh-issue-134970.lgSaxq.rst b/Misc/NEWS.d/next/Library/2025-05-31-12-08-12.gh-issue-134970.lgSaxq.rst
new file mode 100644 (file)
index 0000000..20f5356
--- /dev/null
@@ -0,0 +1,3 @@
+Fix the "unknown action" exception in
+:meth:`argparse.ArgumentParser.add_argument_group` to correctly replace the
+action class.