summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-11-22 15:29:33 (GMT)
committerGitHub <noreply@github.com>2024-11-22 15:29:33 (GMT)
commit0cb4d6c6549d2299f7518f083bbe7d10314ecd66 (patch)
tree702b9453efd01031b859fb14281a03da30bc9394 /Doc
parent46f8a7bbdbb02cafaa00f7bb9478d3d27affc57a (diff)
downloadcpython-0cb4d6c6549d2299f7518f083bbe7d10314ecd66.zip
cpython-0cb4d6c6549d2299f7518f083bbe7d10314ecd66.tar.gz
cpython-0cb4d6c6549d2299f7518f083bbe7d10314ecd66.tar.bz2
gh-86463: Fix default prog in subparsers if usage is used in the main parser (GH-125891)
The usage parameter of argparse.ArgumentParser no longer affects the default value of the prog parameter in subparsers. Previously the full custom usage of the main parser was used as the prog prefix in subparsers.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/argparse.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index a469554..c5882c2 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -192,6 +192,12 @@ arguments it contains. The default message can be overridden with the
The ``%(prog)s`` format specifier is available to fill in the program name in
your usage messages.
+When a custom usage message is specified for the main parser, you may also want to
+consider passing the ``prog`` argument to :meth:`~ArgumentParser.add_subparsers`
+or the ``prog`` and the ``usage`` arguments to
+:meth:`~_SubParsersAction.add_parser`, to ensure consistent command prefixes and
+usage information across subparsers.
+
.. _description:
@@ -1810,6 +1816,10 @@ Sub-commands
.. versionchanged:: 3.7
New *required* keyword-only parameter.
+ .. versionchanged:: 3.14
+ Subparser's *prog* is no longer affected by a custom usage message in
+ the main parser.
+
FileType objects
^^^^^^^^^^^^^^^^