From 2c83e81c51e1d6973a22818c47b4841b44dcb311 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 6 Jun 2023 17:27:37 +0200 Subject: [PATCH 1/2] gh-105373: Remove PyArg_Parse() deprecation There is no plan to deprecate PyArg_Parse(). The deprecation was added as a comment in the C API documentation in 2007 by commit 85eb8c103c9e460917911b43c6be302c30d75efb. --- Doc/c-api/arg.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst index b7cdf293d22380..43a162e55df8b7 100644 --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -439,7 +439,6 @@ API Functions .. versionadded:: 3.2 -.. XXX deprecated, will be removed .. c:function:: int PyArg_Parse(PyObject *args, const char *format, ...) Function used to deconstruct the argument lists of "old-style" functions --- From ecee5868cd91bc45b60522dab6069d8dea84b7f8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Jun 2023 10:51:30 +0200 Subject: [PATCH 2/2] Update PyArg_Parse() documentation --- Doc/c-api/arg.rst | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst index 43a162e55df8b7..d2ea490732fe59 100644 --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -441,13 +441,22 @@ API Functions .. c:function:: int PyArg_Parse(PyObject *args, const char *format, ...) - Function used to deconstruct the argument lists of "old-style" functions --- - these are functions which use the :const:`METH_OLDARGS` parameter parsing - method, which has been removed in Python 3. This is not recommended for use - in parameter parsing in new code, and most code in the standard interpreter - has been modified to no longer use this for that purpose. It does remain a - convenient way to decompose other tuples, however, and may continue to be - used for that purpose. + Parse the parameter of a function that takes a single positional parameter + into a local variable. Returns true on success; on failure, it returns + false and raises the appropriate exception. + + Example:: + + // Function using METH_O calling convention + static PyObject* + my_function(PyObject *module, PyObject *arg) + { + int value; + if (!PyArg_Parse(arg, "i:my_function", &value)) { + return NULL; + } + // ... use value ... + } .. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)