return NULL;
}
- Py_INCREF(key);
- node->key = key;
-
- Py_INCREF(data);
- node->data = data;
+ node->key = Py_NewRef(key);
+ node->data = Py_NewRef(data);
node->prev = NULL;
node->next = NULL;
return -1;
}
- Py_INCREF(factory);
- self->factory = factory;
+ self->factory = Py_NewRef(factory);
self->decref_factory = 1;
self->last = node;
}
- Py_INCREF(node->data);
- return node->data;
+ return Py_NewRef(node->data);
}
PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
/* TODO: have a way to show errors here */
if (!cur_py_value) {
PyErr_Clear();
- Py_INCREF(Py_None);
- cur_py_value = Py_None;
+ cur_py_value = Py_NewRef(Py_None);
}
break;
case SQLITE_BLOB:
break;
case SQLITE_NULL:
default:
- Py_INCREF(Py_None);
- cur_py_value = Py_None;
+ cur_py_value = Py_NewRef(Py_None);
}
if (!cur_py_value) {
flags |= SQLITE_DETERMINISTIC;
#endif
}
- Py_INCREF(func);
rc = sqlite3_create_function_v2(self->db,
name,
narg,
flags,
- (void*)func,
+ (void*)Py_NewRef(func),
_pysqlite_func_callback,
NULL,
NULL,
name,
n_arg,
SQLITE_UTF8,
- (void*)aggregate_class,
+ (void*)Py_NewRef(aggregate_class),
0,
&_pysqlite_step_callback,
&_pysqlite_final_callback,
static PyObject* pysqlite_connection_get_isolation_level(pysqlite_Connection* self, void* unused)
{
- Py_INCREF(self->isolation_level);
- return self->isolation_level;
+ return Py_NewRef(self->isolation_level);
}
static PyObject* pysqlite_connection_get_total_changes(pysqlite_Connection* self, void* unused)
sqlite3_interrupt(self->db);
- Py_INCREF(Py_None);
- retval = Py_None;
+ retval = Py_NewRef(Py_None);
finally:
return retval;
/*[clinic end generated code: output=0f63b8995565ae22 input=5c3898813a776cf2]*/
{
PyObject* uppercase_name = 0;
- PyObject* retval;
Py_ssize_t i, len;
_Py_IDENTIFIER(upper);
const char *uppercase_name_str;
Py_XDECREF(uppercase_name);
if (PyErr_Occurred()) {
- retval = NULL;
- } else {
- Py_INCREF(Py_None);
- retval = Py_None;
+ return NULL;
}
-
- return retval;
+ return Py_NewRef(Py_None);
}
/*[clinic input]
pysqlite_connection_enter_impl(pysqlite_Connection *self)
/*[clinic end generated code: output=457b09726d3e9dcd input=127d7a4f17e86d8f]*/
{
- Py_INCREF(self);
- return (PyObject*)self;
+ return Py_NewRef((PyObject *)self);
}
/*[clinic input]
nbytes = sqlite3_column_bytes(self->statement->st, i);
val_str = (const char*)sqlite3_column_blob(self->statement->st, i);
if (!val_str) {
- Py_INCREF(Py_None);
- converted = Py_None;
+ converted = Py_NewRef(Py_None);
} else {
item = PyBytes_FromStringAndSize(val_str, nbytes);
if (!item)
coltype = sqlite3_column_type(self->statement->st, i);
Py_END_ALLOW_THREADS
if (coltype == SQLITE_NULL) {
- Py_INCREF(Py_None);
- converted = Py_None;
+ converted = Py_NewRef(Py_None);
} else if (coltype == SQLITE_INTEGER) {
converted = PyLong_FromLongLong(sqlite3_column_int64(self->statement->st, i));
} else if (coltype == SQLITE_FLOAT) {
if (PyIter_Check(second_argument)) {
/* iterator */
- Py_INCREF(second_argument);
- parameters_iter = second_argument;
+ parameters_iter = Py_NewRef(second_argument);
} else {
/* sequence */
parameters_iter = PyObject_GetIter(second_argument);
if (!func_args) {
goto error;
}
- Py_INCREF(operation);
- if (PyTuple_SetItem(func_args, 0, operation) != 0) {
+ if (PyTuple_SetItem(func_args, 0, Py_NewRef(operation)) != 0) {
goto error;
}
goto error;
}
PyTuple_SetItem(descriptor, 0, column_name);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 1, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 2, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 3, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 4, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 5, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 6, Py_None);
+ PyTuple_SetItem(descriptor, 1, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 2, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 3, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 4, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 5, Py_NewRef(Py_None));
+ PyTuple_SetItem(descriptor, 6, Py_NewRef(Py_None));
PyTuple_SetItem(self->description, i, descriptor);
}
}
self->rowcount = -1L;
return NULL;
} else {
- Py_INCREF(self);
- return (PyObject*)self;
+ return Py_NewRef((PyObject *)self);
}
}
if (PyErr_Occurred()) {
return NULL;
} else {
- Py_INCREF(self);
- return (PyObject*)self;
+ return Py_NewRef((PyObject *)self);
}
}
}
if (alt) {
- Py_INCREF(alt);
- return alt;
+ return Py_NewRef(alt);
}
/* else set the right exception and return NULL */
PyErr_SetString(pysqlite_ProgrammingError, "can't adapt");
pysqlite_complete_statement_impl(PyObject *module, const char *statement)
/*[clinic end generated code: output=e55f1ff1952df558 input=f6b24996b31c5c33]*/
{
- PyObject* result;
-
if (sqlite3_complete(statement)) {
- result = Py_True;
+ return Py_NewRef(Py_True);
} else {
- result = Py_False;
+ return Py_NewRef(Py_False);
}
-
- Py_INCREF(result);
-
- return result;
}
/*[clinic input]
goto error;
}
- Py_INCREF(Py_None);
- retval = Py_None;
+ retval = Py_NewRef(Py_None);
error:
Py_XDECREF(name);
return retval;
if (self == NULL)
return NULL;
- Py_INCREF(data);
- self->data = data;
-
- Py_INCREF(cursor->description);
- self->description = cursor->description;
+ self->data = Py_NewRef(data);
+ self->description = Py_NewRef(cursor->description);
return (PyObject *) self;
}
PyObject* pysqlite_row_item(pysqlite_Row* self, Py_ssize_t idx)
{
- PyObject* item = PyTuple_GetItem(self->data, idx);
- Py_XINCREF(item);
- return item;
+ PyObject *item = PyTuple_GetItem(self->data, idx);
+ return Py_XNewRef(item);
}
static int
{
Py_ssize_t _idx;
Py_ssize_t nitems, i;
- PyObject* item;
if (PyLong_Check(idx)) {
_idx = PyNumber_AsSsize_t(idx, PyExc_IndexError);
return NULL;
if (_idx < 0)
_idx += PyTuple_GET_SIZE(self->data);
- item = PyTuple_GetItem(self->data, _idx);
- Py_XINCREF(item);
- return item;
+
+ PyObject *item = PyTuple_GetItem(self->data, _idx);
+ return Py_XNewRef(item);
} else if (PyUnicode_Check(idx)) {
nitems = PyTuple_Size(self->description);
}
if (eq) {
/* found item */
- item = PyTuple_GetItem(self->data, i);
- Py_INCREF(item);
- return item;
+ PyObject *item = PyTuple_GetItem(self->data, i);
+ return Py_XNewRef(item);
}
}
}
self->in_weakreflist = NULL;
- Py_INCREF(sql);
- self->sql = sql;
+ self->sql = Py_NewRef(sql);
/* Determine if the statement is a DML statement.
SELECT is the only exception. See #9924. */
}
for (i = 0; i < num_params; i++) {
if (PyTuple_CheckExact(parameters)) {
- current_param = PyTuple_GET_ITEM(parameters, i);
- Py_INCREF(current_param);
+ PyObject *item = PyTuple_GET_ITEM(parameters, i);
+ current_param = Py_NewRef(item);
} else if (PyList_CheckExact(parameters)) {
- current_param = PyList_GetItem(parameters, i);
- Py_XINCREF(current_param);
+ PyObject *item = PyList_GetItem(parameters, i);
+ current_param = Py_XNewRef(item);
} else {
current_param = PySequence_GetItem(parameters, i);
}
return;
}
if (PyDict_CheckExact(parameters)) {
- current_param = PyDict_GetItemWithError(parameters, binding_name_obj);
- Py_XINCREF(current_param);
+ PyObject *item = PyDict_GetItemWithError(parameters, binding_name_obj);
+ current_param = Py_XNewRef(item);
} else {
current_param = PyObject_GetItem(parameters, binding_name_obj);
}