gh-101409: Improve generated clinic code for self type checks (#101411)

This commit is contained in:
Erlend E. Aasland 2023-01-31 21:42:03 +01:00 committed by GitHub
parent 0062f538d9
commit 2753cf2ed6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 80 additions and 78 deletions

View file

@ -16,10 +16,11 @@ static int
pysqlite_cursor_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
PyTypeObject *base_tp = clinic_state()->CursorType;
pysqlite_Connection *connection;
if ((Py_IS_TYPE(self, clinic_state()->CursorType) ||
Py_TYPE(self)->tp_new == clinic_state()->CursorType->tp_new) &&
if ((Py_IS_TYPE(self, base_tp) ||
Py_TYPE(self)->tp_new == base_tp->tp_new) &&
!_PyArg_NoKeywords("Cursor", kwargs)) {
goto exit;
}
@ -318,4 +319,4 @@ pysqlite_cursor_close(pysqlite_Cursor *self, PyObject *Py_UNUSED(ignored))
{
return pysqlite_cursor_close_impl(self);
}
/*[clinic end generated code: output=e53e75a32a9d92bd input=a9049054013a1b77]*/
/*[clinic end generated code: output=1f82e3c9791bb9a5 input=a9049054013a1b77]*/

View file

@ -16,11 +16,11 @@ static PyObject *
pysqlite_row_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
PyTypeObject *base_tp = clinic_state()->RowType;
pysqlite_Cursor *cursor;
PyObject *data;
if ((type == clinic_state()->RowType ||
type->tp_init == clinic_state()->RowType->tp_init) &&
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
!_PyArg_NoKeywords("Row", kwargs)) {
goto exit;
}
@ -60,4 +60,4 @@ pysqlite_row_keys(pysqlite_Row *self, PyObject *Py_UNUSED(ignored))
{
return pysqlite_row_keys_impl(self);
}
/*[clinic end generated code: output=87b91f234633702e input=a9049054013a1b77]*/
/*[clinic end generated code: output=157b31ac3f6af1ba input=a9049054013a1b77]*/