From ec9c9080348efc6f29436ea66ae3e84da797e1df Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Thu, 26 Nov 2026 12:10:29 +0530 Subject: [PATCH] gh-92810: Clear the ABC cache in `_abc._reset_registry` Registered classes are now also added to the positive cache, so `register()` after `_abc_registry_clear()` did nothing for them and the registration was lost once the caches were cleared. This broke the registry restoring of regrtest in refleak mode. --- Modules/_abc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/_abc.c b/Modules/_abc.c index c85e9b2274f031c..79904513c49b643 100644 --- a/Modules/_abc.c +++ b/Modules/_abc.c @@ -565,6 +565,9 @@ _abc__reset_registry(PyObject *module, PyObject *self) if (impl != NULL) { Py_BEGIN_CRITICAL_SECTION(impl); abc_table_clear(&impl->registry); + // Registered classes are also in the cache, and register() + // does nothing for a class which is cached as a subclass. + abc_table_clear(&impl->cache); Py_END_CRITICAL_SECTION(); } _PyThreadState_PopCStackRef(tstate, &cref);