diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-05-31 08:24:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 08:24:56 (GMT) |
commit | d1124b09e8251061dc040cbd396f35ae57783f4a (patch) | |
tree | c2817d08e92a824e483248bee71491f70119306a /Modules/_sqlite/cursor.c | |
parent | 4b20f2574d412f4c4a5b1ab799d8e71a5dd3b766 (diff) | |
download | cpython-d1124b09e8251061dc040cbd396f35ae57783f4a.zip cpython-d1124b09e8251061dc040cbd396f35ae57783f4a.tar.gz cpython-d1124b09e8251061dc040cbd396f35ae57783f4a.tar.bz2 |
bpo-42972: Fix sqlite3 traverse/clear functions (GH-26452)
Diffstat (limited to 'Modules/_sqlite/cursor.c')
-rw-r--r-- | Modules/_sqlite/cursor.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index b3e1ce2..4eb9c6d 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); } |