summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/_testclinic.c.h
diff options
context:
space:
mode:
authorcolorfulappl <colorfulappl@qq.com>2022-11-24 12:24:18 (GMT)
committerGitHub <noreply@github.com>2022-11-24 12:24:18 (GMT)
commit69f6cc77d0f1664f983a83b6ae707d99a99f5c4f (patch)
tree4efabca7535e491a1e43901ab255b8cd1c65beec /Modules/clinic/_testclinic.c.h
parentae185fdcca9d48aef425468de8a8a31300280932 (diff)
downloadcpython-69f6cc77d0f1664f983a83b6ae707d99a99f5c4f.zip
cpython-69f6cc77d0f1664f983a83b6ae707d99a99f5c4f.tar.gz
cpython-69f6cc77d0f1664f983a83b6ae707d99a99f5c4f.tar.bz2
gh-64490: Fix refcount error when arguments are packed to tuple in argument clinic (#99233)
Diffstat (limited to 'Modules/clinic/_testclinic.c.h')
-rw-r--r--Modules/clinic/_testclinic.c.h67
1 files changed, 66 insertions, 1 deletions
diff --git a/Modules/clinic/_testclinic.c.h b/Modules/clinic/_testclinic.c.h
index b0ac4c2..eb42582 100644
--- a/Modules/clinic/_testclinic.c.h
+++ b/Modules/clinic/_testclinic.c.h
@@ -2288,4 +2288,69 @@ keyword_only_parameter(PyObject *module, PyObject *const *args, Py_ssize_t nargs
exit:
return return_value;
}
-/*[clinic end generated code: output=a9212f8e6ba18bba input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(vararg_and_posonly__doc__,
+"vararg_and_posonly($module, a, /, *args)\n"
+"--\n"
+"\n");
+
+#define VARARG_AND_POSONLY_METHODDEF \
+ {"vararg_and_posonly", _PyCFunction_CAST(vararg_and_posonly), METH_FASTCALL, vararg_and_posonly__doc__},
+
+static PyObject *
+vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args);
+
+static PyObject *
+vararg_and_posonly(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *a;
+ PyObject *__clinic_args = NULL;
+
+ if (!_PyArg_CheckPositional("vararg_and_posonly", nargs, 1, PY_SSIZE_T_MAX)) {
+ goto exit;
+ }
+ a = args[0];
+ __clinic_args = PyTuple_New(nargs - 1);
+ for (Py_ssize_t i = 0; i < nargs - 1; ++i) {
+ PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[1 + i]));
+ }
+ return_value = vararg_and_posonly_impl(module, a, __clinic_args);
+
+exit:
+ Py_XDECREF(__clinic_args);
+ return return_value;
+}
+
+PyDoc_STRVAR(gh_99233_refcount__doc__,
+"gh_99233_refcount($module, /, *args)\n"
+"--\n"
+"\n"
+"Proof-of-concept of GH-99233 refcount error bug.");
+
+#define GH_99233_REFCOUNT_METHODDEF \
+ {"gh_99233_refcount", _PyCFunction_CAST(gh_99233_refcount), METH_FASTCALL, gh_99233_refcount__doc__},
+
+static PyObject *
+gh_99233_refcount_impl(PyObject *module, PyObject *args);
+
+static PyObject *
+gh_99233_refcount(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *__clinic_args = NULL;
+
+ if (!_PyArg_CheckPositional("gh_99233_refcount", nargs, 0, PY_SSIZE_T_MAX)) {
+ goto exit;
+ }
+ __clinic_args = PyTuple_New(nargs - 0);
+ for (Py_ssize_t i = 0; i < nargs - 0; ++i) {
+ PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[0 + i]));
+ }
+ return_value = gh_99233_refcount_impl(module, __clinic_args);
+
+exit:
+ Py_XDECREF(__clinic_args);
+ return return_value;
+}
+/*[clinic end generated code: output=a5c9f181f3a32d85 input=a9049054013a1b77]*/