[3.12] gh-121084: Call _abc_registry_clear() when checking refleaks (GH-121191) (#121209)

gh-121084: Call _abc_registry_clear() when checking refleaks (GH-121191)

dash_R_cleanup() now calls _abc_registry_clear() before calling again
register().
(cherry picked from commit c766ad206e)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2024-07-01 11:29:23 +02:00 committed by GitHub
parent b80edafff2
commit 3fba86e8b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -239,9 +239,13 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
abs_classes = filter(isabstract, abs_classes) abs_classes = filter(isabstract, abs_classes)
for abc in abs_classes: for abc in abs_classes:
for obj in abc.__subclasses__() + [abc]: for obj in abc.__subclasses__() + [abc]:
for ref in abcs.get(obj, set()): refs = abcs.get(obj, None)
if ref() is not None: if refs is not None:
obj.register(ref()) obj._abc_registry_clear()
for ref in refs:
subclass = ref()
if subclass is not None:
obj.register(subclass)
obj._abc_caches_clear() obj._abc_caches_clear()
# Clear caches # Clear caches