Skip to content

Commit 3014816

Browse files
picnixzYhg1s
authored andcommitted
fix error path in _PyImport_LazyImportModuleLevelObject
1 parent 74f35c4 commit 3014816

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/import.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4371,7 +4371,9 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate,
43714371
Py_DECREF(filter);
43724372
Py_DECREF(abs_name);
43734373
return NULL;
4374-
} else if (modname == NULL) {
4374+
}
4375+
if (modname == NULL) {
4376+
assert(!PyErr_Occurred());
43754377
modname = Py_NewRef(Py_None);
43764378
}
43774379
PyObject *args[] = {modname, name, fromlist};
@@ -4405,6 +4407,7 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate,
44054407
}
44064408
}
44074409

4410+
// here, 'filter' is either NULL or is equivalent to a borrowed reference
44084411
PyObject *res = _PyLazyImport_New(builtins, abs_name, fromlist);
44094412
if (res == NULL) {
44104413
Py_DECREF(abs_name);

0 commit comments

Comments
 (0)