File tree Expand file tree Collapse file tree 1 file changed +3
-13
lines changed
Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments