Skip to content

Commit 07e3b65

Browse files
Don't bother making the module temporary.
1 parent 05acc56 commit 07e3b65

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

Modules/_datetimemodule.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,12 @@ _get_current_state(PyObject **p_mod)
135135
if (PyErr_Occurred()) {
136136
return NULL;
137137
}
138-
/* The static types can outlive the module, so we must
139-
* temporarily load the module if one of the static types'
140-
* methods needs module state. We can cut some corners
141-
* since the module was necessarily already imported successfully
142-
* and the module will only be around temporarily. We don't even
143-
* need a spec. Normally the module would have been found
144-
* and the temporary module would never happen. */
145-
mod = PyModule_New("_datetime");
138+
/* The static types can outlive the module,
139+
* so we must re-import the module. */
140+
mod = PyImport_ImportModule("_datetime");
146141
if (mod == NULL) {
147142
return NULL;
148143
}
149-
((PyModuleObject*)mod)->md_def = &datetimemodule;
150-
if (PyModule_ExecDef(mod, &datetimemodule) < 0) {
151-
Py_DECREF(mod);
152-
return NULL;
153-
}
154144
}
155145
datetime_state *st = get_module_state(mod);
156146
*p_mod = mod;

0 commit comments

Comments
 (0)