diff options
Diffstat (limited to 'Modules/_io/bytesio.c')
-rw-r--r-- | Modules/_io/bytesio.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index cafe4a2..e3a7849 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -609,11 +609,14 @@ bytesio_close(bytesio *self) static void bytesio_dealloc(bytesio *self) { + _PyObject_GC_UNTRACK(self); if (self->buf != NULL) { PyMem_Free(self->buf); self->buf = NULL; } - Py_TYPE(self)->tp_clear((PyObject *)self); + Py_CLEAR(self->dict); + if (self->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) self); Py_TYPE(self)->tp_free(self); } @@ -669,7 +672,6 @@ static int bytesio_traverse(bytesio *self, visitproc visit, void *arg) { Py_VISIT(self->dict); - Py_VISIT(self->weakreflist); return 0; } @@ -677,8 +679,6 @@ static int bytesio_clear(bytesio *self) { Py_CLEAR(self->dict); - if (self->weakreflist != NULL) - PyObject_ClearWeakRefs((PyObject *)self); return 0; } |