* Fix refleak in C module __init_subclass__
This was leaking a reference to the weak cache dictionary for every
ZoneInfo subclass created.
* Fix refleak in ZoneInfo subclass's clear_cache
The previous version of the code accidentally cleared the global
ZONEINFO_STRONG_CACHE variable (and inducing `ZoneInfo` to create a new
strong cache) on calls to a subclass's `clear_cache()`. This would not
affect guaranteed behavior, but it's still not the right thing to do
(and it caused reference leaks).
}
clear_strong_cache(type);
- ZONEINFO_STRONG_CACHE = NULL;
}
else {
PyObject *item = NULL;
}
strong_cache_free(ZONEINFO_STRONG_CACHE);
+ ZONEINFO_STRONG_CACHE = NULL;
}
static PyObject *
}
PyObject_SetAttrString((PyObject *)cls, "_weak_cache", weak_cache);
+ Py_DECREF(weak_cache);
Py_RETURN_NONE;
}
Py_CLEAR(ZONEINFO_WEAK_CACHE);
}
- strong_cache_free(ZONEINFO_STRONG_CACHE);
- ZONEINFO_STRONG_CACHE = NULL;
+ clear_strong_cache(&PyZoneInfo_ZoneInfoType);
}
static int