File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -2490,6 +2490,7 @@ new_weak_cache()
24902490static int
24912491initialize_caches ()
24922492{
2493+ // TODO: Move to a PyModule_GetState / PEP 573 based caching system.
24932494 if (TIMEDELTA_CACHE == NULL ) {
24942495 TIMEDELTA_CACHE = PyDict_New ();
24952496 }
@@ -2603,14 +2604,16 @@ module_free()
26032604
26042605 xdecref_ttinfo (& NO_TTINFO );
26052606
2606- Py_XDECREF (TIMEDELTA_CACHE );
2607- if (!Py_REFCNT (TIMEDELTA_CACHE )) {
2608- TIMEDELTA_CACHE = NULL ;
2607+ if (TIMEDELTA_CACHE != NULL && Py_REFCNT (TIMEDELTA_CACHE ) > 1 ) {
2608+ Py_DECREF (TIMEDELTA_CACHE );
2609+ } else {
2610+ Py_CLEAR (TIMEDELTA_CACHE );
26092611 }
26102612
2611- Py_XDECREF (ZONEINFO_WEAK_CACHE );
2612- if (!Py_REFCNT (ZONEINFO_WEAK_CACHE )) {
2613- ZONEINFO_WEAK_CACHE = NULL ;
2613+ if (ZONEINFO_WEAK_CACHE != NULL && Py_REFCNT (ZONEINFO_WEAK_CACHE ) > 1 ) {
2614+ Py_DECREF (ZONEINFO_WEAK_CACHE );
2615+ } else {
2616+ Py_CLEAR (ZONEINFO_WEAK_CACHE );
26142617 }
26152618
26162619 strong_cache_free (ZONEINFO_STRONG_CACHE );
You can’t perform that action at this time.
0 commit comments