Skip to content

Commit a018d44

Browse files
committed
fix
1 parent 27784cd commit a018d44

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Objects/dictobject.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,9 +3425,6 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
34253425
if (d == NULL) {
34263426
return NULL;
34273427
}
3428-
// The constructor returns a tracked object; keep it untracked while it is
3429-
// filled and GC-track it once complete.
3430-
_PyObject_GC_UNTRACK(d);
34313428

34323429
// If cls is a dict or frozendict subclass with overridden constructor,
34333430
// copy the frozendict.
@@ -3453,6 +3450,11 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
34533450
}
34543451
assert(!PyFrozenDict_Check(d) || can_modify_dict((PyDictObject*)d));
34553452

3453+
// Keep d untracked while it is filled; GC-track it once complete (done:).
3454+
if (_PyObject_GC_IS_TRACKED(d)) {
3455+
_PyObject_GC_UNTRACK(d);
3456+
}
3457+
34563458
if (PyDict_CheckExact(d)) {
34573459
if (PyDict_CheckExact(iterable)) {
34583460
PyDictObject *mp = (PyDictObject *)d;

0 commit comments

Comments
 (0)