Skip to content

Commit ebc3fc5

Browse files
committed
gh-153797: Fix crash when re-importing extension modules after OOM
Fix a crash that could occur after an out-of-memory error when re-importing an extension module.
1 parent 4f3be1b commit ebc3fc5

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash that could occur after an out-of-memory error when re-importing
2+
an extension module.

Python/import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,7 @@ reload_singlephase_extension(PyThreadState *tstate,
20082008

20092009
Py_ssize_t index = _get_cached_module_index(cached);
20102010
if (_modules_by_index_set(tstate->interp, index, mod) < 0) {
2011-
PyMapping_DelItem(modules, info->name);
2011+
remove_module(tstate, info->name);
20122012
Py_DECREF(mod);
20132013
return NULL;
20142014
}

0 commit comments

Comments
 (0)