Skip to content

Commit 33c64f2

Browse files
committed
revert lazy
1 parent d3944fe commit 33c64f2

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

Modules/_datetimemodule.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,13 +1887,6 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
18871887
if (st == NULL) {
18881888
return NULL;
18891889
}
1890-
if (st->time_strftime == NULL) {
1891-
st->time_strftime = PyImport_ImportModuleAttrString("time", "strftime");
1892-
if (st->time_strftime == NULL) {
1893-
RELEASE_CURRENT_STATE(st, current_mod);
1894-
return NULL;
1895-
}
1896-
}
18971890
PyObject *strftime = st->time_strftime;
18981891

18991892
/* Scan the input format, looking for %z/%Z/%f escapes, building
@@ -2078,13 +2071,6 @@ build_struct_time(int y, int m, int d, int hh, int mm, int ss, int dstflag)
20782071
if (st == NULL) {
20792072
return NULL;
20802073
}
2081-
if (st->time_struct_time == NULL) {
2082-
st->time_struct_time = PyImport_ImportModuleAttrString("time", "struct_time");
2083-
if (st->time_struct_time == NULL) {
2084-
RELEASE_CURRENT_STATE(st, current_mod);
2085-
return NULL;
2086-
}
2087-
}
20882074

20892075
PyObject *result = PyObject_CallFunction(st->time_struct_time,
20902076
"((iiiiiiiii))",
@@ -7468,8 +7454,14 @@ init_state(datetime_state *st, PyObject *module, PyObject *old_module)
74687454
return -1;
74697455
}
74707456

7471-
st->time_struct_time = NULL;
7472-
st->time_strftime = NULL;
7457+
st->time_struct_time = PyImport_ImportModuleAttrString("time", "struct_time");
7458+
if (st->time_struct_time == NULL) {
7459+
return -1;
7460+
}
7461+
st->time_strftime = PyImport_ImportModuleAttrString("time", "strftime");
7462+
if (st->time_strftime == NULL) {
7463+
return -1;
7464+
}
74737465

74747466
return 0;
74757467
}

0 commit comments

Comments
 (0)