From: Michał Górny Date: Sun, 1 Jun 2025 05:56:56 +0000 (+0200) Subject: gh-134970: Fix exception message in argparse module (GH-134971) X-Git-Tag: v3.15.0a1~1426 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=965c48056633d3f4b41520c8cd07f0275f00fb4c;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Lib/argparse.py b/Lib/argparse.py index d1a6350c3fda..83258cf3e0f3 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 000000000000..20f53569ef45 --- /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.