summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/cursor.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-31 09:12:27 (GMT)
committerGitHub <noreply@github.com>2021-05-31 09:12:27 (GMT)
commitff359d735f1a60878975d1c5751bfd2361e84067 (patch)
treef27c50e4432a9ee27ab1686298163301ce9b5149 /Modules/_sqlite/cursor.c
parentd338ce0796e5fe8e54dfe52f93ed9d5936ad3efe (diff)
downloadcpython-ff359d735f1a60878975d1c5751bfd2361e84067.zip
cpython-ff359d735f1a60878975d1c5751bfd2361e84067.tar.gz
cpython-ff359d735f1a60878975d1c5751bfd2361e84067.tar.bz2
bpo-42972: Fix sqlite3 traverse/clear functions (GH-26452) (GH-26461)
(cherry picked from commit d1124b09e8251061dc040cbd396f35ae57783f4a) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Diffstat (limited to 'Modules/_sqlite/cursor.c')
-rw-r--r--Modules/_sqlite/cursor.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index acd3ea2..558b43a 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -84,43 +84,44 @@ pysqlite_cursor_init_impl(pysqlite_Cursor *self,
static int
cursor_traverse(pysqlite_Cursor *self, visitproc visit, void *arg)
{
+ Py_VISIT(Py_TYPE(self));
Py_VISIT(self->connection);
+ Py_VISIT(self->description);
Py_VISIT(self->row_cast_map);
+ Py_VISIT(self->lastrowid);
Py_VISIT(self->row_factory);
+ Py_VISIT(self->statement);
Py_VISIT(self->next_row);
- Py_VISIT(Py_TYPE(self));
return 0;
}
static int
cursor_clear(pysqlite_Cursor *self)
{
- /* Reset the statement if the user has not closed the cursor */
- if (self->statement) {
- pysqlite_statement_reset(self->statement);
- Py_CLEAR(self->statement);
- }
-
Py_CLEAR(self->connection);
- Py_CLEAR(self->row_cast_map);
Py_CLEAR(self->description);
+ Py_CLEAR(self->row_cast_map);
Py_CLEAR(self->lastrowid);
Py_CLEAR(self->row_factory);
- Py_CLEAR(self->next_row);
-
- if (self->in_weakreflist != NULL) {
- PyObject_ClearWeakRefs((PyObject*)self);
+ if (self->statement) {
+ /* Reset the statement if the user has not closed the cursor */
+ pysqlite_statement_reset(self->statement);
+ Py_CLEAR(self->statement);
}
+ Py_CLEAR(self->next_row);
return 0;
}
static void
-cursor_dealloc(PyObject *self)
+cursor_dealloc(pysqlite_Cursor *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
- tp->tp_clear(self);
+ if (self->in_weakreflist != NULL) {
+ PyObject_ClearWeakRefs((PyObject*)self);
+ }
+ tp->tp_clear((PyObject *)self);
tp->tp_free(self);
Py_DECREF(tp);
}