Skip to content

Commit a8c9468

Browse files
Add some asserts to _PyImport_RunModInitFunc().
1 parent a815f20 commit a8c9468

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Python/importdl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ _PyImport_RunModInitFunc(PyModInitFunction p0,
256256

257257
res.def = PyModule_GetDef(m);
258258
if (res.def == NULL) {
259+
PyErr_Clear();
259260
PyErr_Format(PyExc_SystemError,
260261
"initialization of %s did not return an extension "
261262
"module", name_buf);
@@ -266,10 +267,12 @@ _PyImport_RunModInitFunc(PyModInitFunction p0,
266267
res.def->m_base.m_init = p0;
267268
}
268269

270+
assert(!PyErr_Occurred());
269271
*p_res = res;
270272
return 0;
271273

272274
error:
275+
assert(PyErr_Occurred());
273276
Py_CLEAR(res.module);
274277
res.def = NULL;
275278
*p_res = res;

0 commit comments

Comments
 (0)