]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-151722: Defer GC tracking in frozendict.copy() (#152230)
authorVictor Stinner <vstinner@python.org>
Fri, 26 Jun 2026 11:55:54 +0000 (13:55 +0200)
committerGitHub <noreply@github.com>
Fri, 26 Jun 2026 11:55:54 +0000 (13:55 +0200)
commit05679f3576ed3298c9b0f86e8a3462f0b92dff8f
tree9f772379b88a2a3d8293fbe4e8946e0eee5869c8
parent72cad148cb6bd6ef34f4a377e4618cb73933c9b1
gh-151722: Defer GC tracking in frozendict.copy() (#152230)

Fix _PyDict_Or() and frozendict.copy(): only track the frozendict by
the GC once the dictionary is fully initialized.

Functions modifying frozendict now ensures that the object is not
tracked by the GC (in debug mode).

* can_modify_dict() checks that _PyObject_GC_IS_TRACKED() is false
  for frozendicts.
* dict_merge_api() makes sure that the dictionary is tracked by the
  GC.
Objects/dictobject.c