Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Modules/_zoneinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,7 @@ new_weak_cache()
static int
initialize_caches()
{
// TODO: Move to a PyModule_GetState / PEP 573 based caching system.
if (TIMEDELTA_CACHE == NULL) {
TIMEDELTA_CACHE = PyDict_New();
}
Expand Down Expand Up @@ -2603,14 +2604,16 @@ module_free()

xdecref_ttinfo(&NO_TTINFO);

Py_XDECREF(TIMEDELTA_CACHE);
if (!Py_REFCNT(TIMEDELTA_CACHE)) {
TIMEDELTA_CACHE = NULL;
if (TIMEDELTA_CACHE != NULL && Py_REFCNT(TIMEDELTA_CACHE) > 1) {
Py_DECREF(TIMEDELTA_CACHE);
} else {
Py_CLEAR(TIMEDELTA_CACHE);
}

Py_XDECREF(ZONEINFO_WEAK_CACHE);
if (!Py_REFCNT(ZONEINFO_WEAK_CACHE)) {
ZONEINFO_WEAK_CACHE = NULL;
if (ZONEINFO_WEAK_CACHE != NULL && Py_REFCNT(ZONEINFO_WEAK_CACHE) > 1) {
Py_DECREF(ZONEINFO_WEAK_CACHE);
} else {
Py_CLEAR(ZONEINFO_WEAK_CACHE);
}

strong_cache_free(ZONEINFO_STRONG_CACHE);
Expand Down