Skip to content

Commit ecee586

Browse files
committed
Update PyArg_Parse() documentation
1 parent 2c83e81 commit ecee586

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Doc/c-api/arg.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,22 @@ API Functions
441441
442442
.. c:function:: int PyArg_Parse(PyObject *args, const char *format, ...)
443443
444-
Function used to deconstruct the argument lists of "old-style" functions ---
445-
these are functions which use the :const:`METH_OLDARGS` parameter parsing
446-
method, which has been removed in Python 3. This is not recommended for use
447-
in parameter parsing in new code, and most code in the standard interpreter
448-
has been modified to no longer use this for that purpose. It does remain a
449-
convenient way to decompose other tuples, however, and may continue to be
450-
used for that purpose.
444+
Parse the parameter of a function that takes a single positional parameter
445+
into a local variable. Returns true on success; on failure, it returns
446+
false and raises the appropriate exception.
447+
448+
Example::
449+
450+
// Function using METH_O calling convention
451+
static PyObject*
452+
my_function(PyObject *module, PyObject *arg)
453+
{
454+
int value;
455+
if (!PyArg_Parse(arg, "i:my_function", &value)) {
456+
return NULL;
457+
}
458+
// ... use value ...
459+
}
451460
452461
453462
.. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)

0 commit comments

Comments
 (0)