Skip to content

Commit f96a99c

Browse files
picnixzYhg1s
authored andcommitted
fix error path in _imp__set_lazy_attributes_impl
1 parent 3014816 commit f96a99c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Python/import.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5464,12 +5464,15 @@ _imp__set_lazy_attributes_impl(PyObject *module, PyObject *child_module,
54645464
}
54655465

54665466
child_dict = get_mod_dict(child_module);
5467-
if (child_dict == NULL || !PyDict_CheckExact(child_dict)) {
5467+
if (child_dict == NULL) {
5468+
goto error;
5469+
}
5470+
else if (!PyDict_CheckExact(child_dict)) {
54685471
goto done;
54695472
}
54705473
assert(PyAnySet_CheckExact(lazy_submodules));
5471-
PyObject *attr_name;
54725474
Py_ssize_t pos = 0;
5475+
PyObject *attr_name;
54735476
Py_hash_t hash;
54745477
while (_PySet_NextEntry(lazy_submodules, &pos, &attr_name, &hash)) {
54755478
if (_PyDict_Contains_KnownHash(child_dict, attr_name, hash)) {
@@ -5491,10 +5494,11 @@ _imp__set_lazy_attributes_impl(PyObject *module, PyObject *child_module,
54915494
goto error;
54925495
}
54935496
}
5497+
54945498
done:
54955499
ret = Py_NewRef(Py_None);
54965500

5497-
error:
5501+
error:
54985502
Py_XDECREF(lazy_modules);
54995503
Py_XDECREF(child_dict);
55005504
return ret;

0 commit comments

Comments
 (0)