bpo-42972: Fix sqlite3 traverse/clear functions (GH-26452)

This commit is contained in:
Erlend Egeberg Aasland 2021-05-31 10:24:56 +02:00 committed by GitHub
parent 4b20f2574d
commit d1124b09e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 44 deletions

View file

@ -373,6 +373,9 @@ stmt_dealloc(pysqlite_Statement *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
if (self->in_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject*)self);
}
tp->tp_clear((PyObject *)self);
tp->tp_free(self);
Py_DECREF(tp);
@ -389,17 +392,14 @@ stmt_clear(pysqlite_Statement *self)
}
Py_CLEAR(self->sql);
if (self->in_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject*)self);
}
return 0;
}
static int
stmt_traverse(pysqlite_Statement *self, visitproc visit, void *arg)
{
Py_VISIT(self->sql);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->sql);
return 0;
}