diff -r 1340e298aa7e Python/import.c --- a/Python/import.c Wed Aug 31 08:22:29 2016 +0100 +++ b/Python/import.c Wed Aug 31 19:15:38 2016 +0800 @@ -1941,19 +1941,15 @@ def = PyModule_GetDef(mod); if (def == NULL) { - if (PyErr_Occurred()) { - return -1; - } return 0; } + state = PyModule_GetState(mod); - if (PyErr_Occurred()) { - return -1; - } if (state) { /* Already initialized; skip reload */ return 0; } + return PyModule_ExecDef(mod, def); }