Skip to content

Commit 79528af

Browse files
committed
Rephrase the NEWS entry
1 parent a7726f2 commit 79528af

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
:meth:`!frozendict.fromkeys` now creates a :class:`frozendict` which is not
2-
tracked by the garbage collector, and only tracks it once the dictionary is
3-
fully initialized. Patch by Donghee Na and Victor Stinner.
1+
:meth:`!frozendict.fromkeys` now only tracks the :class:`frozendict` in the
2+
garbage collector once the dictionary is fully initialized. Patch by Donghee Na
3+
and Victor Stinner.

Objects/dictobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3436,6 +3436,9 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
34363436

34373437
// gh-151722: If cls constructor returns a frozendict which is tracked by
34383438
// the GC, create a frozendict copy which is not tracked by the GC.
3439+
//
3440+
// Untracking the dictionary requires tracking again the dictionary on
3441+
// error which is more complicated. It's easier to work on a copy.
34393442
if (PyFrozenDict_Check(d) && _PyObject_GC_IS_TRACKED(d)) {
34403443
// Subclass-friendly copy
34413444
PyObject *copy = frozendict_new_untracked(Py_TYPE(d));
@@ -3448,8 +3451,8 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
34483451
}
34493452
Py_SETREF(d, copy);
34503453
}
3451-
assert(!PyFrozenDict_Check(d) || can_modify_dict((PyDictObject*)d));
34523454
if (PyFrozenDict_Check(d)) {
3455+
assert(can_modify_dict((PyDictObject*)d));
34533456
assert(!_PyObject_GC_IS_TRACKED(d));
34543457
}
34553458

0 commit comments

Comments
 (0)