summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-24 08:35:59 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-24 08:35:59 (GMT)
commit5a57ade58ec5bee85db41b8ce1340ff077781b65 (patch)
tree2f8cf61efba46284b2d4437916bc3469d23c0ce3 /Modules/_sqlite
parenta198645fa0f9a9c6183c211955083765dc8ab3a8 (diff)
downloadcpython-5a57ade58ec5bee85db41b8ce1340ff077781b65.zip
cpython-5a57ade58ec5bee85db41b8ce1340ff077781b65.tar.gz
cpython-5a57ade58ec5bee85db41b8ce1340ff077781b65.tar.bz2
Issue #20440: Massive replacing unsafe attribute setting code with special
macro Py_SETREF.
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/connection.c13
-rw-r--r--Modules/_sqlite/cursor.c13
2 files changed, 10 insertions, 16 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index a08ebfe..7018f9f 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -204,8 +204,8 @@ void pysqlite_flush_statement_cache(pysqlite_Connection* self)
node = node->next;
}
- Py_DECREF(self->statement_cache);
- self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "O", self);
+ Py_SETREF(self->statement_cache,
+ (pysqlite_Cache *)PyObject_CallFunction((PyObject *)&pysqlite_CacheType, "O", self));
Py_DECREF(self);
self->statement_cache->decref_factory = 0;
}
@@ -318,9 +318,8 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args,
_pysqlite_drop_unused_cursor_references(self);
if (cursor && self->row_factory != Py_None) {
- Py_XDECREF(((pysqlite_Cursor*)cursor)->row_factory);
Py_INCREF(self->row_factory);
- ((pysqlite_Cursor*)cursor)->row_factory = self->row_factory;
+ Py_SETREF(((pysqlite_Cursor *)cursor)->row_factory, self->row_factory);
}
return cursor;
@@ -795,8 +794,7 @@ static void _pysqlite_drop_unused_statement_references(pysqlite_Connection* self
}
}
- Py_DECREF(self->statements);
- self->statements = new_list;
+ Py_SETREF(self->statements, new_list);
}
static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self)
@@ -827,8 +825,7 @@ static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self)
}
}
- Py_DECREF(self->cursors);
- self->cursors = new_list;
+ Py_SETREF(self->cursors, new_list);
}
PyObject* pysqlite_connection_create_function(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index c1599c0..d909738 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -170,8 +170,7 @@ int pysqlite_build_row_cast_map(pysqlite_Cursor* self)
return 0;
}
- Py_XDECREF(self->row_cast_map);
- self->row_cast_map = PyList_New(0);
+ Py_SETREF(self->row_cast_map, PyList_New(0));
for (i = 0; i < sqlite3_column_count(self->statement->st); i++) {
converter = NULL;
@@ -510,9 +509,8 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
goto error;
/* reset description and rowcount */
- Py_DECREF(self->description);
Py_INCREF(Py_None);
- self->description = Py_None;
+ Py_SETREF(self->description, Py_None);
self->rowcount = -1L;
func_args = PyTuple_New(1);
@@ -537,8 +535,8 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
}
if (self->statement->in_use) {
- Py_DECREF(self->statement);
- self->statement = PyObject_New(pysqlite_Statement, &pysqlite_StatementType);
+ Py_SETREF(self->statement,
+ PyObject_New(pysqlite_Statement, &pysqlite_StatementType));
if (!self->statement) {
goto error;
}
@@ -654,8 +652,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
numcols = sqlite3_column_count(self->statement->st);
Py_END_ALLOW_THREADS
- Py_DECREF(self->description);
- self->description = PyTuple_New(numcols);
+ Py_SETREF(self->description, PyTuple_New(numcols));
if (!self->description) {
goto error;
}