@@ -186,15 +186,15 @@ static int
186
186
eject_from_strong_cache (zoneinfo_state * state , const PyTypeObject * const type ,
187
187
PyObject * key );
188
188
static void
189
- clear_strong_cache (const PyTypeObject * const type );
189
+ clear_strong_cache (zoneinfo_state * state , const PyTypeObject * const type );
190
190
static void
191
191
update_strong_cache (zoneinfo_state * state , const PyTypeObject * const type ,
192
192
PyObject * key , PyObject * zone );
193
193
static PyObject *
194
194
zone_from_strong_cache (zoneinfo_state * state , const PyTypeObject * const type ,
195
195
PyObject * const key );
196
196
197
- zoneinfo_state * zoneinfo_get_state ()
197
+ zoneinfo_state * zoneinfo_get_state (PyObject * mod )
198
198
{
199
199
return & global_state ;
200
200
}
@@ -280,7 +280,7 @@ zoneinfo_new_instance(zoneinfo_state *state, PyTypeObject *type, PyObject *key)
280
280
static PyObject *
281
281
get_weak_cache (zoneinfo_state * state , PyTypeObject * type )
282
282
{
283
- if (type == zoneinfo_get_state () -> ZoneInfoType ) {
283
+ if (type == state -> ZoneInfoType ) {
284
284
return state -> ZONEINFO_WEAK_CACHE ;
285
285
}
286
286
else {
@@ -489,7 +489,7 @@ zoneinfo_ZoneInfo_clear_cache_impl(PyTypeObject *type, PyTypeObject *cls,
489
489
Py_DECREF (rv );
490
490
}
491
491
492
- clear_strong_cache (type );
492
+ clear_strong_cache (state , type );
493
493
}
494
494
else {
495
495
PyObject * item = NULL ;
@@ -2605,9 +2605,8 @@ update_strong_cache(zoneinfo_state *state, const PyTypeObject *const type,
2605
2605
* for everything except the base class.
2606
2606
*/
2607
2607
void
2608
- clear_strong_cache (const PyTypeObject * const type )
2608
+ clear_strong_cache (zoneinfo_state * state , const PyTypeObject * const type )
2609
2609
{
2610
- zoneinfo_state * state = zoneinfo_get_state ();
2611
2610
if (type != state -> ZoneInfoType ) {
2612
2611
return ;
2613
2612
}
@@ -2736,7 +2735,7 @@ static PyMethodDef module_methods[] = {{NULL, NULL}};
2736
2735
static void
2737
2736
module_free (void * m )
2738
2737
{
2739
- zoneinfo_state * state = zoneinfo_get_state ();
2738
+ zoneinfo_state * state = zoneinfo_get_state (m );
2740
2739
2741
2740
Py_CLEAR (state -> io_open );
2742
2741
Py_CLEAR (state -> _tzpath_find_tzfile );
@@ -2762,7 +2761,7 @@ module_free(void *m)
2762
2761
Py_CLEAR (state -> ZONEINFO_WEAK_CACHE );
2763
2762
}
2764
2763
2765
- clear_strong_cache (zoneinfo_get_state () -> ZoneInfoType );
2764
+ clear_strong_cache (state , state -> ZoneInfoType );
2766
2765
}
2767
2766
2768
2767
static int
@@ -2773,7 +2772,7 @@ zoneinfomodule_exec(PyObject *m)
2773
2772
goto error ;
2774
2773
}
2775
2774
2776
- zoneinfo_state * state = zoneinfo_get_state ();
2775
+ zoneinfo_state * state = zoneinfo_get_state (m );
2777
2776
PyObject * base = (PyObject * )PyDateTimeAPI -> TZInfoType ;
2778
2777
state -> ZoneInfoType = (PyTypeObject * )PyType_FromModuleAndSpec (m ,
2779
2778
& zoneinfo_spec , base );
0 commit comments