]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-46417: Fix race condition on setting type __bases__ (GH-30788) (GH-30790)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 22 Jan 2022 14:28:42 +0000 (06:28 -0800)
committerGitHub <noreply@github.com>
Sat, 22 Jan 2022 14:28:42 +0000 (15:28 +0100)
commitf1796f29478f08f34e0c30a060622c0b2d843e2c
tree06bcdcf9a0ccb4d0edbd6d45d2b43ca711b4be49
parent6ed874f8c59cc6c01d9663bad2f4bed8dc1c6109
bpo-46417: Fix race condition on setting type __bases__ (GH-30788) (GH-30790)

Fix a race condition on setting a type __bases__ attribute: the
internal function add_subclass() now gets the
PyTypeObject.tp_subclasses member after calling PyWeakref_NewRef()
which can trigger a garbage collection which can indirectly modify
PyTypeObject.tp_subclasses.
(cherry picked from commit f1c6ae3270913e095d24ae13ecf96f5a32c8c503)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
Misc/NEWS.d/next/Core and Builtins/2022-01-22-14-39-23.bpo-46417.3U5SfN.rst [new file with mode: 0644]
Objects/typeobject.c