]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.15] gh-151722: Defer GC tracking in frozendict.copy() (GH-152230) (#152271)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 26 Jun 2026 12:26:17 +0000 (14:26 +0200)
committerGitHub <noreply@github.com>
Fri, 26 Jun 2026 12:26:17 +0000 (12:26 +0000)
commitc48673b4b6eb0544bc70a99a2ff5ce5238c12b1a
tree5f3dca2067a74822449cea49671f7aaa68923be5
parent62842c9ff592114ade3049d6a85aea031b783beb
[3.15] gh-151722: Defer GC tracking in frozendict.copy() (GH-152230) (#152271)

gh-151722: Defer GC tracking in frozendict.copy() (GH-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.
(cherry picked from commit 05679f3576ed3298c9b0f86e8a3462f0b92dff8f)

Co-authored-by: Victor Stinner <vstinner@python.org>
Objects/dictobject.c