Skip to content

Commit 5756201

Browse files
Call _PyImport_RunModInitFunc() in reload_singlephase_extension().
1 parent 21d259e commit 5756201

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Python/import.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ import_find_extension(PyThreadState *tstate,
13131313
if (def == NULL) {
13141314
return NULL;
13151315
}
1316+
assert(is_singlephase(def));
13161317

13171318
/* It may have been successfully imported previously
13181319
in an interpreter that allows legacy modules
@@ -1360,12 +1361,16 @@ import_find_extension(PyThreadState *tstate,
13601361
|| _PyModule_GetDef(mod) == def);
13611362
}
13621363
else {
1363-
if (def->m_base.m_init == NULL)
1364+
if (def->m_base.m_init == NULL) {
13641365
return NULL;
1365-
mod = def->m_base.m_init();
1366-
if (mod == NULL) {
1366+
}
1367+
struct _Py_ext_module_loader_result res;
1368+
if (_PyImport_RunModInitFunc(def->m_base.m_init, info, &res) < 0) {
13671369
return NULL;
13681370
}
1371+
assert(!PyErr_Occurred());
1372+
mod = res.module;
1373+
// XXX __file__ doesn't get set!
13691374
if (PyObject_SetItem(modules, info->name, mod) == -1) {
13701375
Py_DECREF(mod);
13711376
return NULL;

0 commit comments

Comments
 (0)