Kaydet (Commit) 94a64e9c authored tarafından Zackery Spytz's avatar Zackery Spytz Kaydeden (comit) Nick Coghlan

bpo-24048: Save the live exception during import.c's remove_module() (GH-13005)

Save the live exception during the course of remove_module().
üst 85225b6a
Save the live exception during import.c's ``remove_module()``.
...@@ -837,14 +837,18 @@ PyImport_AddModule(const char *name) ...@@ -837,14 +837,18 @@ PyImport_AddModule(const char *name)
static void static void
remove_module(PyObject *name) remove_module(PyObject *name)
{ {
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
PyObject *modules = PyImport_GetModuleDict(); PyObject *modules = PyImport_GetModuleDict();
if (!PyMapping_HasKey(modules, name)) {
goto out;
}
if (PyMapping_DelItem(modules, name) < 0) { if (PyMapping_DelItem(modules, name) < 0) {
if (!PyMapping_HasKey(modules, name)) {
return;
}
Py_FatalError("import: deleting existing key in " Py_FatalError("import: deleting existing key in "
"sys.modules failed"); "sys.modules failed");
} }
out:
PyErr_Restore(type, value, traceback);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment