mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-24048: Save the live exception during import.c's remove_module() (GH-13005)
Save the live exception during the course of remove_module().
This commit is contained in:
parent
85225b6a58
commit
94a64e9cd4
2 changed files with 8 additions and 3 deletions
|
@ -837,14 +837,18 @@ PyImport_AddModule(const char *name)
|
|||
static void
|
||||
remove_module(PyObject *name)
|
||||
{
|
||||
PyObject *type, *value, *traceback;
|
||||
PyErr_Fetch(&type, &value, &traceback);
|
||||
PyObject *modules = PyImport_GetModuleDict();
|
||||
if (!PyMapping_HasKey(modules, name)) {
|
||||
goto out;
|
||||
}
|
||||
if (PyMapping_DelItem(modules, name) < 0) {
|
||||
if (!PyMapping_HasKey(modules, name)) {
|
||||
return;
|
||||
}
|
||||
Py_FatalError("import: deleting existing key in "
|
||||
"sys.modules failed");
|
||||
}
|
||||
out:
|
||||
PyErr_Restore(type, value, traceback);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue