Skip to content

Commit 4c31528

Browse files
Add module arg to zoneinfo_get_state()
1 parent 5e71905 commit 4c31528

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Modules/_zoneinfo.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ static int
186186
eject_from_strong_cache(zoneinfo_state *state, const PyTypeObject *const type,
187187
PyObject *key);
188188
static void
189-
clear_strong_cache(const PyTypeObject *const type);
189+
clear_strong_cache(zoneinfo_state *state, const PyTypeObject *const type);
190190
static void
191191
update_strong_cache(zoneinfo_state *state, const PyTypeObject *const type,
192192
PyObject *key, PyObject *zone);
193193
static PyObject *
194194
zone_from_strong_cache(zoneinfo_state *state, const PyTypeObject *const type,
195195
PyObject *const key);
196196

197-
zoneinfo_state *zoneinfo_get_state()
197+
zoneinfo_state *zoneinfo_get_state(PyObject *mod)
198198
{
199199
return &global_state;
200200
}
@@ -280,7 +280,7 @@ zoneinfo_new_instance(zoneinfo_state *state, PyTypeObject *type, PyObject *key)
280280
static PyObject *
281281
get_weak_cache(zoneinfo_state *state, PyTypeObject *type)
282282
{
283-
if (type == zoneinfo_get_state()->ZoneInfoType) {
283+
if (type == state->ZoneInfoType) {
284284
return state->ZONEINFO_WEAK_CACHE;
285285
}
286286
else {
@@ -489,7 +489,7 @@ zoneinfo_ZoneInfo_clear_cache_impl(PyTypeObject *type, PyTypeObject *cls,
489489
Py_DECREF(rv);
490490
}
491491

492-
clear_strong_cache(type);
492+
clear_strong_cache(state, type);
493493
}
494494
else {
495495
PyObject *item = NULL;
@@ -2605,9 +2605,8 @@ update_strong_cache(zoneinfo_state *state, const PyTypeObject *const type,
26052605
* for everything except the base class.
26062606
*/
26072607
void
2608-
clear_strong_cache(const PyTypeObject *const type)
2608+
clear_strong_cache(zoneinfo_state *state, const PyTypeObject *const type)
26092609
{
2610-
zoneinfo_state *state = zoneinfo_get_state();
26112610
if (type != state->ZoneInfoType) {
26122611
return;
26132612
}
@@ -2736,7 +2735,7 @@ static PyMethodDef module_methods[] = {{NULL, NULL}};
27362735
static void
27372736
module_free(void *m)
27382737
{
2739-
zoneinfo_state *state = zoneinfo_get_state();
2738+
zoneinfo_state *state = zoneinfo_get_state(m);
27402739

27412740
Py_CLEAR(state->io_open);
27422741
Py_CLEAR(state->_tzpath_find_tzfile);
@@ -2762,7 +2761,7 @@ module_free(void *m)
27622761
Py_CLEAR(state->ZONEINFO_WEAK_CACHE);
27632762
}
27642763

2765-
clear_strong_cache(zoneinfo_get_state()->ZoneInfoType);
2764+
clear_strong_cache(state, state->ZoneInfoType);
27662765
}
27672766

27682767
static int
@@ -2773,7 +2772,7 @@ zoneinfomodule_exec(PyObject *m)
27732772
goto error;
27742773
}
27752774

2776-
zoneinfo_state *state = zoneinfo_get_state();
2775+
zoneinfo_state *state = zoneinfo_get_state(m);
27772776
PyObject *base = (PyObject *)PyDateTimeAPI->TZInfoType;
27782777
state->ZoneInfoType = (PyTypeObject *)PyType_FromModuleAndSpec(m,
27792778
&zoneinfo_spec, base);

0 commit comments

Comments
 (0)