@@ -143,18 +143,6 @@ pysqlite_cursor_init_impl(pysqlite_Cursor *self,
143143 return 0 ;
144144}
145145
146- static PyObject *
147- pysqlite_cursor_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
148- {
149- pysqlite_Cursor * self = (pysqlite_Cursor * )type -> tp_alloc (type , 0 );
150- if (self == NULL ) {
151- return NULL ;
152- }
153- // row_factory should never be uninitialized, even if tp_init is bypassed.
154- self -> row_factory = Py_NewRef (Py_None );
155- return (PyObject * )self ;
156- }
157-
158146static inline int
159147stmt_reset (pysqlite_Statement * self )
160148{
@@ -425,9 +413,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
425413 }
426414
427415 nbytes = sqlite3_column_bytes (self -> statement -> st , i );
428- PyObject * text_factory = self -> connection -> text_factory ;
429- if (text_factory == NULL ||
430- text_factory == (PyObject * )& PyUnicode_Type ) {
416+ if (self -> connection -> text_factory == (PyObject * )& PyUnicode_Type ) {
431417 converted = PyUnicode_FromStringAndSize (text , nbytes );
432418 if (!converted && PyErr_ExceptionMatches (PyExc_UnicodeDecodeError )) {
433419 PyErr_Clear ();
@@ -448,12 +434,12 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
448434 Py_DECREF (error_msg );
449435 }
450436 }
451- } else if (text_factory == (PyObject * )& PyBytes_Type ) {
437+ } else if (self -> connection -> text_factory == (PyObject * )& PyBytes_Type ) {
452438 converted = PyBytes_FromStringAndSize (text , nbytes );
453- } else if (text_factory == (PyObject * )& PyByteArray_Type ) {
439+ } else if (self -> connection -> text_factory == (PyObject * )& PyByteArray_Type ) {
454440 converted = PyByteArray_FromStringAndSize (text , nbytes );
455441 } else {
456- converted = PyObject_CallFunction (text_factory , "y#" , text , nbytes );
442+ converted = PyObject_CallFunction (self -> connection -> text_factory , "y#" , text , nbytes );
457443 }
458444 } else {
459445 /* coltype == SQLITE_BLOB */
@@ -1190,7 +1176,7 @@ pysqlite_cursor_iternext(PyObject *op)
11901176 }
11911177 return NULL ;
11921178 }
1193- if (self -> row_factory != NULL && !Py_IsNone (self -> row_factory )) {
1179+ if (!Py_IsNone (self -> row_factory )) {
11941180 PyObject * factory = self -> row_factory ;
11951181 PyObject * args [] = { op , row , };
11961182 PyObject * new_row = PyObject_Vectorcall (factory , args , 2 , NULL );
@@ -1422,8 +1408,7 @@ static PyObject *
14221408cursor_get_row_factory (PyObject * op , void * closure )
14231409{
14241410 pysqlite_Cursor * self = (pysqlite_Cursor * )op ;
1425- PyObject * row_factory = self -> row_factory ;
1426- return Py_NewRef (row_factory != NULL ? row_factory : Py_None );
1411+ return Py_NewRef (self -> row_factory );
14271412}
14281413
14291414static int
@@ -1456,7 +1441,6 @@ static PyType_Slot cursor_slots[] = {
14561441 {Py_tp_methods , cursor_methods },
14571442 {Py_tp_members , cursor_members },
14581443 {Py_tp_getset , cursor_getsets },
1459- {Py_tp_new , pysqlite_cursor_new },
14601444 {Py_tp_init , pysqlite_cursor_init },
14611445 {Py_tp_traverse , cursor_traverse },
14621446 {Py_tp_clear , cursor_clear },
0 commit comments