Skip to content

Commit d4e4f54

Browse files
committed
GC fix
1 parent 29ff77c commit d4e4f54

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arraydeque.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,14 @@ ArrayDeque_iter(ArrayDequeObject *self)
482482
return (PyObject *)it;
483483
}
484484

485-
/* __new__ method: allocate a new ArrayDeque */
485+
/* __new__ method: allocate a new ArrayDeque.
486+
This version uses PyObject_GC_New to ensure that the object
487+
is not already tracked by the garbage collector (fixing issues on macOS). */
486488
static PyObject *
487489
ArrayDeque_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
488490
{
489491
ArrayDequeObject *self;
490-
self = (ArrayDequeObject *)type->tp_alloc(type, 0);
492+
self = PyObject_GC_New(ArrayDequeObject, type);
491493
if (self == NULL)
492494
return NULL;
493495
self->weakreflist = NULL;

0 commit comments

Comments
 (0)