Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Doc/c-api/arg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,17 @@ API Functions
}


.. c:function:: int PyArg_ParseVector(PyObject *const *args, Py_ssize_t nargs, const char *format, ...)

Parse the parameters of a function that takes only vector parameters into
local variables; function using the :c:macro:`METH_FASTCALL` calling
Comment thread
vstinner marked this conversation as resolved.
Outdated
convention.
Returns true on success; on failure, it returns false and raises the
appropriate exception.

.. versionadded:: 3.15
Comment thread
vstinner marked this conversation as resolved.
Outdated


.. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)

A simpler form of parameter retrieval which does not use a format string to
Expand Down
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,10 @@ C API changes
New features
------------

* Add :c:func:`PyArg_ParseVector` function to parse arguments of functions
using the :c:macro:`METH_FASTCALL` calling convention.
(Contributed by Victor Stinner in :gh:`144175`.)

* Add :c:func:`PySys_GetAttr`, :c:func:`PySys_GetAttrString`,
:c:func:`PySys_GetOptionalAttr`, and :c:func:`PySys_GetOptionalAttrString`
functions as replacements for :c:func:`PySys_GetObject`.
Expand Down
6 changes: 6 additions & 0 deletions Include/cpython/modsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# error "this header file must not be included directly"
#endif

PyAPI_FUNC(int) PyArg_ParseVector(
PyObject *const *args,
Py_ssize_t nargs,
const char *format,
...);

// A data structure that can be used to run initialization code once in a
// thread-safe manner. The C++11 equivalent is std::call_once.
typedef struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add :c:func:`PyArg_ParseVector` function to parse arguments of functions
using the :c:macro:`METH_FASTCALL` calling convention. Patch by Victor
Stinner.
10 changes: 10 additions & 0 deletions Python/getargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ _PyArg_ParseStack(PyObject *const *args, Py_ssize_t nargs, const char *format, .
return retval;
}

int
PyArg_ParseVector(PyObject *const *args, Py_ssize_t nargs, const char *format, ...)
{
va_list va;
va_start(va, format);
int retval = vgetargs1_impl(NULL, args, nargs, format, &va, 0);
va_end(va);
return retval;
}

int
PyArg_VaParse(PyObject *args, const char *format, va_list va)
{
Expand Down
Loading