File tree 1 file changed +7
-0
lines changed 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -426,6 +426,11 @@ _PyImport_RunModInitFunc(PyModInitFunction p0,
426
426
/* Validate the result (and populate "res". */
427
427
428
428
if (m == NULL ) {
429
+ /* The init func for multi-phase init modules is expected
430
+ * to return a PyModuleDef after calling PyModuleDef_Init().
431
+ * That function never raises an exception nor returns NULL,
432
+ * so at this point it must be a single-phase init modules. */
433
+ res .kind = _Py_ext_module_kind_SINGLEPHASE ;
429
434
if (PyErr_Occurred ()) {
430
435
_Py_ext_module_loader_result_set_error (
431
436
& res , _Py_ext_module_loader_result_EXCEPTION );
@@ -436,6 +441,8 @@ _PyImport_RunModInitFunc(PyModInitFunction p0,
436
441
}
437
442
goto error ;
438
443
} else if (PyErr_Occurred ()) {
444
+ /* Likewise, we infer that this is a single-phase init module. */
445
+ res .kind = _Py_ext_module_kind_SINGLEPHASE ;
439
446
_Py_ext_module_loader_result_set_error (
440
447
& res , _Py_ext_module_loader_result_ERR_UNREPORTED_EXC );
441
448
/* We would probably be correct to decref m here,
You can’t perform that action at this time.
0 commit comments