https://github.com/python/cpython/commit/c80eacde5924a0b696d910d2712e0aa51263755c
commit: c80eacde5924a0b696d910d2712e0aa51263755c
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-08-07T07:36:09+03:00
summary:

[3.13] gh-74366: Fix the documentation of "$" in PyArg_ParseTupleAndKeywords() 
(GH-155301) (GH-155310)

The keyword-only arguments are not always optional: they are required if
"|" was not specified before "$".  Document also that "|" cannot be
specified after "$", and add examples for "|" and "$".
(cherry picked from commit af930c13787a15c22187d5d526f74f35c95f8056)

Co-authored-by: Serhiy Storchaka <[email protected]>

files:
M Doc/c-api/arg.rst

diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst
index 6f74eff71d00e3..a3e76cadf5671c 100644
--- a/Doc/c-api/arg.rst
+++ b/Doc/c-api/arg.rst
@@ -371,13 +371,18 @@ inside nested parentheses.  They are:
    their default value --- when an optional argument is not specified,
    :c:func:`PyArg_ParseTuple` does not touch the contents of the corresponding 
C
    variable(s).
+   For example, the format string ``"OO|OO"`` corresponds to the Python
+   signature ``f(a, b, c=None, d=None)``.
 
 ``$``
    :c:func:`PyArg_ParseTupleAndKeywords` only:
    Indicates that the remaining arguments in the Python argument list are
-   keyword-only.  Currently, all keyword-only arguments must also be optional
-   arguments, so ``|`` must always be specified before ``$`` in the format
-   string.
+   keyword-only.
+   They are optional if ``|`` was specified before ``$``, and required 
otherwise.
+   ``|`` cannot be specified after ``$``.
+   For example, the format string ``"O|O$O"`` corresponds to the Python
+   signature ``f(a, b=None, *, c=None)``,
+   and the format string ``"OO$OO"`` corresponds to ``f(a, b, *, c, d)``.
 
    .. versionadded:: 3.3
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to