gh-111178: Change Argument Clinic signature for METH_O (#130682)

Use "PyObject*" for METH_O functions to fix an undefined behavior.
This commit is contained in:
Victor Stinner 2025-03-11 16:33:36 +01:00 committed by GitHub
parent 4162bc133b
commit 9d759b63d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 843 additions and 190 deletions

View file

@ -1195,6 +1195,20 @@ PyDoc_STRVAR(pysqlite_connection_executescript__doc__,
#define PYSQLITE_CONNECTION_EXECUTESCRIPT_METHODDEF \
{"executescript", (PyCFunction)pysqlite_connection_executescript, METH_O, pysqlite_connection_executescript__doc__},
static PyObject *
pysqlite_connection_executescript_impl(pysqlite_Connection *self,
PyObject *script_obj);
static PyObject *
pysqlite_connection_executescript(PyObject *self, PyObject *script_obj)
{
PyObject *return_value = NULL;
return_value = pysqlite_connection_executescript_impl((pysqlite_Connection *)self, script_obj);
return return_value;
}
PyDoc_STRVAR(pysqlite_connection_interrupt__doc__,
"interrupt($self, /)\n"
"--\n"
@ -1881,4 +1895,4 @@ exit:
#ifndef DESERIALIZE_METHODDEF
#define DESERIALIZE_METHODDEF
#endif /* !defined(DESERIALIZE_METHODDEF) */
/*[clinic end generated code: output=c59effb407b8ea4d input=a9049054013a1b77]*/
/*[clinic end generated code: output=fc4857f09ad563b1 input=a9049054013a1b77]*/

View file

@ -262,6 +262,19 @@ PyDoc_STRVAR(pysqlite_cursor_setinputsizes__doc__,
#define PYSQLITE_CURSOR_SETINPUTSIZES_METHODDEF \
{"setinputsizes", (PyCFunction)pysqlite_cursor_setinputsizes, METH_O, pysqlite_cursor_setinputsizes__doc__},
static PyObject *
pysqlite_cursor_setinputsizes_impl(pysqlite_Cursor *self, PyObject *sizes);
static PyObject *
pysqlite_cursor_setinputsizes(PyObject *self, PyObject *sizes)
{
PyObject *return_value = NULL;
return_value = pysqlite_cursor_setinputsizes_impl((pysqlite_Cursor *)self, sizes);
return return_value;
}
PyDoc_STRVAR(pysqlite_cursor_setoutputsize__doc__,
"setoutputsize($self, size, column=None, /)\n"
"--\n"
@ -314,4 +327,4 @@ pysqlite_cursor_close(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return pysqlite_cursor_close_impl((pysqlite_Cursor *)self);
}
/*[clinic end generated code: output=82620ca7622b547c input=a9049054013a1b77]*/
/*[clinic end generated code: output=02831aed7377f5f6 input=a9049054013a1b77]*/

View file

@ -1908,9 +1908,9 @@ Executes multiple SQL statements at once.
[clinic start generated code]*/
static PyObject *
pysqlite_connection_executescript(pysqlite_Connection *self,
PyObject *script_obj)
/*[clinic end generated code: output=4c4f9d77aa0ae37d input=f6e5f1ccfa313db4]*/
pysqlite_connection_executescript_impl(pysqlite_Connection *self,
PyObject *script_obj)
/*[clinic end generated code: output=e921c49e2291782c input=f6e5f1ccfa313db4]*/
{
PyObject* result = 0;

View file

@ -1243,8 +1243,8 @@ Required by DB-API. Does nothing in sqlite3.
[clinic start generated code]*/
static PyObject *
pysqlite_cursor_setinputsizes(pysqlite_Cursor *self, PyObject *sizes)
/*[clinic end generated code: output=893c817afe9d08ad input=de7950a3aec79bdf]*/
pysqlite_cursor_setinputsizes_impl(pysqlite_Cursor *self, PyObject *sizes)
/*[clinic end generated code: output=a06c12790bd05f2e input=de7950a3aec79bdf]*/
{
Py_RETURN_NONE;
}