Skip to content

Commit cd4c52d

Browse files
We already know the def is okay.
1 parent 1e4af72 commit cd4c52d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Python/import.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ finish_singlephase_extension(PyThreadState *tstate,
12701270
PyObject *name, PyObject *modules)
12711271
{
12721272
assert(mod != NULL && PyModule_Check(mod));
1273-
assert(def == PyModule_GetDef(mod));
1273+
assert(def == _PyModule_GetDef(mod));
12741274

12751275
if (_modules_by_index_set(tstate->interp, def, mod) < 0) {
12761276
return -1;
@@ -1419,9 +1419,17 @@ create_dynamic(PyThreadState *tstate, struct _Py_ext_module_loader_info *info,
14191419
goto finally;
14201420
}
14211421

1422-
if (res.module == NULL) {
1423-
//assert(!is_singlephase(res.def));
1424-
mod = PyModule_FromDefAndSpec(res.def, spec);
1422+
mod = res.module;
1423+
res.module = NULL;
1424+
def = res.def;
1425+
assert(def != NULL);
1426+
1427+
if (mod == NULL) {
1428+
//assert(!is_singlephase(def));
1429+
mod = PyModule_FromDefAndSpec(def, spec);
1430+
if (mod == NULL) {
1431+
goto finally;
1432+
}
14251433
}
14261434
else {
14271435
assert(is_singlephase(res.def));

0 commit comments

Comments
 (0)