@@ -32,35 +32,41 @@ void pysqlite_row_dealloc(pysqlite_Row* self)
3232 Py_TYPE (self )-> tp_free ((PyObject * )self );
3333}
3434
35- int pysqlite_row_init (pysqlite_Row * self , PyObject * args , PyObject * kwargs )
35+ static PyObject *
36+ pysqlite_row_new (PyTypeObject * type , PyObject * args , PyObject * kwargs )
3637{
38+ pysqlite_Row * self ;
3739 PyObject * data ;
3840 pysqlite_Cursor * cursor ;
3941
40- self -> data = 0 ;
41- self -> description = 0 ;
42+ assert (type != NULL && type -> tp_alloc != NULL );
4243
43- if (!PyArg_ParseTuple (args , "OO" , & cursor , & data )) {
44- return -1 ;
45- }
44+ if (!_PyArg_NoKeywords ("Row()" , kwargs ))
45+ return NULL ;
46+ if (!PyArg_ParseTuple (args , "OO" , & cursor , & data ))
47+ return NULL ;
4648
4749 if (!PyObject_IsInstance ((PyObject * )cursor , (PyObject * )& pysqlite_CursorType )) {
4850 PyErr_SetString (PyExc_TypeError , "instance of cursor required for first argument" );
49- return -1 ;
51+ return NULL ;
5052 }
5153
5254 if (!PyTuple_Check (data )) {
5355 PyErr_SetString (PyExc_TypeError , "tuple required for second argument" );
54- return -1 ;
56+ return NULL ;
5557 }
5658
59+ self = (pysqlite_Row * ) type -> tp_alloc (type , 0 );
60+ if (self == NULL )
61+ return NULL ;
62+
5763 Py_INCREF (data );
5864 self -> data = data ;
5965
6066 Py_INCREF (cursor -> description );
6167 self -> description = cursor -> description ;
6268
63- return 0 ;
69+ return ( PyObject * ) self ;
6470}
6571
6672PyObject * pysqlite_row_item (pysqlite_Row * self , Py_ssize_t idx )
@@ -260,15 +266,15 @@ PyTypeObject pysqlite_RowType = {
260266 0 , /* tp_descr_get */
261267 0 , /* tp_descr_set */
262268 0 , /* tp_dictoffset */
263- ( initproc ) pysqlite_row_init , /* tp_init */
269+ 0 , /* tp_init */
264270 0 , /* tp_alloc */
265271 0 , /* tp_new */
266272 0 /* tp_free */
267273};
268274
269275extern int pysqlite_row_setup_types (void )
270276{
271- pysqlite_RowType .tp_new = PyType_GenericNew ;
277+ pysqlite_RowType .tp_new = pysqlite_row_new ;
272278 pysqlite_RowType .tp_as_mapping = & pysqlite_row_as_mapping ;
273279 pysqlite_RowType .tp_as_sequence = & pysqlite_row_as_sequence ;
274280 return PyType_Ready (& pysqlite_RowType );
0 commit comments