mirror of
https://github.com/python/cpython.git
synced 2025-10-27 16:57:08 +00:00
Issue #26282: PyArg_ParseTupleAndKeywords() and Argument Clinic now support
positional-only and keyword parameters in the same function.
This commit is contained in:
parent
339880809a
commit
f41b82fb19
9 changed files with 210 additions and 72 deletions
|
|
@ -406,8 +406,15 @@ API Functions
|
|||
.. c:function:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...)
|
||||
|
||||
Parse the parameters of a function that takes both positional and keyword
|
||||
parameters into local variables. Returns true on success; on failure, it
|
||||
returns false and raises the appropriate exception.
|
||||
parameters into local variables. The *keywords* argument is a
|
||||
*NULL*-terminated array of keyword parameter names. Empty names denote
|
||||
:ref:`positional-only parameters <positional-only_parameter>`.
|
||||
Returns true on success; on failure, it returns false and raises the
|
||||
appropriate exception.
|
||||
|
||||
.. versionchanged:: 3.6
|
||||
Added support for :ref:`positional-only parameters
|
||||
<positional-only_parameter>`.
|
||||
|
||||
|
||||
.. c:function:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs)
|
||||
|
|
|
|||
|
|
@ -718,6 +718,8 @@ Glossary
|
|||
|
||||
def func(foo, bar=None): ...
|
||||
|
||||
.. _positional-only_parameter:
|
||||
|
||||
* :dfn:`positional-only`: specifies an argument that can be supplied only
|
||||
by position. Python has no syntax for defining positional-only
|
||||
parameters. However, some built-in functions have positional-only
|
||||
|
|
|
|||
|
|
@ -503,6 +503,11 @@ Build and C API Changes
|
|||
* New :c:func:`Py_FinalizeEx` API which indicates if flushing buffered data
|
||||
failed (:issue:`5319`).
|
||||
|
||||
* :c:func:`PyArg_ParseTupleAndKeywords` now supports :ref:`positional-only
|
||||
parameters <positional-only_parameter>`. Positional-only parameters are
|
||||
defined by empty names.
|
||||
(Contributed by Serhit Storchaka in :issue:`26282`).
|
||||
|
||||
|
||||
Deprecated
|
||||
==========
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue