@@ -271,8 +271,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
271
271
nbytes = sqlite3_column_bytes (self -> statement -> st , i );
272
272
val_str = (const char * )sqlite3_column_blob (self -> statement -> st , i );
273
273
if (!val_str ) {
274
- Py_INCREF (Py_None );
275
- converted = Py_None ;
274
+ converted = Py_NewRef (Py_None );
276
275
} else {
277
276
item = PyBytes_FromStringAndSize (val_str , nbytes );
278
277
if (!item )
@@ -285,8 +284,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self)
285
284
coltype = sqlite3_column_type (self -> statement -> st , i );
286
285
Py_END_ALLOW_THREADS
287
286
if (coltype == SQLITE_NULL ) {
288
- Py_INCREF (Py_None );
289
- converted = Py_None ;
287
+ converted = Py_NewRef (Py_None );
290
288
} else if (coltype == SQLITE_INTEGER ) {
291
289
converted = PyLong_FromLongLong (sqlite3_column_int64 (self -> statement -> st , i ));
292
290
} else if (coltype == SQLITE_FLOAT ) {
@@ -402,8 +400,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
402
400
403
401
if (PyIter_Check (second_argument )) {
404
402
/* iterator */
405
- Py_INCREF (second_argument );
406
- parameters_iter = second_argument ;
403
+ parameters_iter = Py_NewRef (second_argument );
407
404
} else {
408
405
/* sequence */
409
406
parameters_iter = PyObject_GetIter (second_argument );
@@ -456,8 +453,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
456
453
if (!func_args ) {
457
454
goto error ;
458
455
}
459
- Py_INCREF (operation );
460
- if (PyTuple_SetItem (func_args , 0 , operation ) != 0 ) {
456
+ if (PyTuple_SetItem (func_args , 0 , Py_NewRef (operation )) != 0 ) {
461
457
goto error ;
462
458
}
463
459
@@ -555,12 +551,12 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
555
551
goto error ;
556
552
}
557
553
PyTuple_SetItem (descriptor , 0 , column_name );
558
- Py_INCREF ( Py_None ); PyTuple_SetItem (descriptor , 1 , Py_None );
559
- Py_INCREF ( Py_None ); PyTuple_SetItem (descriptor , 2 , Py_None );
560
- Py_INCREF ( Py_None ); PyTuple_SetItem (descriptor , 3 , Py_None );
561
- Py_INCREF ( Py_None ); PyTuple_SetItem (descriptor , 4 , Py_None );
562
- Py_INCREF ( Py_None ); PyTuple_SetItem (descriptor , 5 , Py_None );
563
- Py_INCREF ( Py_None ); PyTuple_SetItem (descriptor , 6 , Py_None );
554
+ PyTuple_SetItem (descriptor , 1 , Py_NewRef ( Py_None ) );
555
+ PyTuple_SetItem (descriptor , 2 , Py_NewRef ( Py_None ) );
556
+ PyTuple_SetItem (descriptor , 3 , Py_NewRef ( Py_None ) );
557
+ PyTuple_SetItem (descriptor , 4 , Py_NewRef ( Py_None ) );
558
+ PyTuple_SetItem (descriptor , 5 , Py_NewRef ( Py_None ) );
559
+ PyTuple_SetItem (descriptor , 6 , Py_NewRef ( Py_None ) );
564
560
PyTuple_SetItem (self -> description , i , descriptor );
565
561
}
566
562
}
@@ -610,8 +606,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
610
606
self -> rowcount = -1L ;
611
607
return NULL ;
612
608
} else {
613
- Py_INCREF (self );
614
- return (PyObject * )self ;
609
+ return Py_NewRef ((PyObject * )self );
615
610
}
616
611
}
617
612
@@ -706,8 +701,7 @@ pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
706
701
if (PyErr_Occurred ()) {
707
702
return NULL ;
708
703
} else {
709
- Py_INCREF (self );
710
- return (PyObject * )self ;
704
+ return Py_NewRef ((PyObject * )self );
711
705
}
712
706
}
713
707
0 commit comments