File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -2490,6 +2490,7 @@ new_weak_cache()
2490
2490
static int
2491
2491
initialize_caches ()
2492
2492
{
2493
+ // TODO: Move to a PyModule_GetState / PEP 573 based caching system.
2493
2494
if (TIMEDELTA_CACHE == NULL ) {
2494
2495
TIMEDELTA_CACHE = PyDict_New ();
2495
2496
}
@@ -2603,14 +2604,16 @@ module_free()
2603
2604
2604
2605
xdecref_ttinfo (& NO_TTINFO );
2605
2606
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 );
2609
2611
}
2610
2612
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 );
2614
2617
}
2615
2618
2616
2619
strong_cache_free (ZONEINFO_STRONG_CACHE );
You can’t perform that action at this time.
0 commit comments