summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2025-06-01 06:21:34 (GMT)
committerGitHub <noreply@github.com>2025-06-01 06:21:34 (GMT)
commitdf7247a3802f44234b923e3149b0cc11d6133bb7 (patch)
tree1aa73f8940dd03ada21459b98526c06163fe2292
parent7c1dfd9c988be07c14892177db6b512e4983ca20 (diff)
downloadcpython-df7247a3802f44234b923e3149b0cc11d6133bb7.zip
cpython-df7247a3802f44234b923e3149b0cc11d6133bb7.tar.gz
cpython-df7247a3802f44234b923e3149b0cc11d6133bb7.tar.bz2
[3.14] gh-134970: Fix exception message in argparse module (GH-134971) (GH-134991)
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>
-rw-r--r--Lib/argparse.py2
-rw-r--r--Misc/NEWS.d/next/Library/2025-05-31-12-08-12.gh-issue-134970.lgSaxq.rst3
2 files changed, 4 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index d1a6350..83258cf 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -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
index 0000000..20f5356
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-05-31-12-08-12.gh-issue-134970.lgSaxq.rst
@@ -0,0 +1,3 @@
+Fix the "unknown action" exception in
+:meth:`argparse.ArgumentParser.add_argument_group` to correctly replace the
+action class.