aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_sqlite/row.c')
-rw-r--r--Modules/_sqlite/row.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 9086c19af73..04e308fa1c3 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -23,6 +23,13 @@
#include "row.h"
#include "cursor.h"
+#include "clinic/row.c.h"
+
+/*[clinic input]
+module _sqlite3
+class _sqlite3.Row "pysqlite_Row *" "pysqlite_RowType"
+[clinic start generated code]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=384227da65f250fd]*/
void pysqlite_row_dealloc(pysqlite_Row* self)
{
@@ -35,30 +42,25 @@ void pysqlite_row_dealloc(pysqlite_Row* self)
Py_DECREF(tp);
}
+/*[clinic input]
+@classmethod
+_sqlite3.Row.__new__ as pysqlite_row_new
+
+ cursor: object(type='pysqlite_Cursor *', subclass_of='pysqlite_CursorType')
+ data: object(subclass_of='&PyTuple_Type')
+ /
+
+[clinic start generated code]*/
+
static PyObject *
-pysqlite_row_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+pysqlite_row_new_impl(PyTypeObject *type, pysqlite_Cursor *cursor,
+ PyObject *data)
+/*[clinic end generated code: output=10d58b09a819a4c1 input=f6cd7e6e0935828d]*/
{
pysqlite_Row *self;
- PyObject* data;
- pysqlite_Cursor* cursor;
assert(type != NULL && type->tp_alloc != NULL);
- if (!_PyArg_NoKeywords("Row", kwargs))
- return NULL;
- if (!PyArg_ParseTuple(args, "OO", &cursor, &data))
- return NULL;
-
- if (!PyObject_TypeCheck((PyObject*)cursor, pysqlite_CursorType)) {
- PyErr_SetString(PyExc_TypeError, "instance of cursor required for first argument");
- return NULL;
- }
-
- if (!PyTuple_Check(data)) {
- PyErr_SetString(PyExc_TypeError, "tuple required for second argument");
- return NULL;
- }
-
self = (pysqlite_Row *) type->tp_alloc(type, 0);
if (self == NULL)
return NULL;
@@ -153,7 +155,15 @@ pysqlite_row_length(pysqlite_Row* self)
return PyTuple_GET_SIZE(self->data);
}
-PyObject* pysqlite_row_keys(pysqlite_Row* self, PyObject *Py_UNUSED(ignored))
+/*[clinic input]
+_sqlite3.Row.keys as pysqlite_row_keys
+
+Returns the keys of the row.
+[clinic start generated code]*/
+
+static PyObject *
+pysqlite_row_keys_impl(pysqlite_Row *self)
+/*[clinic end generated code: output=efe3dfb3af6edc07 input=7549a122827c5563]*/
{
PyObject* list;
Py_ssize_t nitems, i;
@@ -204,8 +214,7 @@ static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other,
}
static PyMethodDef row_methods[] = {
- {"keys", (PyCFunction)pysqlite_row_keys, METH_NOARGS,
- PyDoc_STR("Returns the keys of the row.")},
+ PYSQLITE_ROW_KEYS_METHODDEF
{NULL, NULL}
};