diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-05-29 19:35:21 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-29 19:35:21 (GMT) |
| commit | 5aa40e587e63bcad22c7e196fc3559e2b5e0792b (patch) | |
| tree | 010815a27080cb1784572eadf7cffd5b8d879a51 /Python | |
| parent | 852e8a7ed4d3d48e5c1c8120cfc932eb6a84bb8e (diff) | |
| download | cpython-5aa40e587e63bcad22c7e196fc3559e2b5e0792b.zip cpython-5aa40e587e63bcad22c7e196fc3559e2b5e0792b.tar.gz cpython-5aa40e587e63bcad22c7e196fc3559e2b5e0792b.tar.bz2 | |
bpo-24048: Save the live exception during import.c's remove_module() (GH-13005)
Save the live exception during the course of remove_module().
(cherry picked from commit 94a64e9cd411a87514b68082c1c437eb3b49dfb9)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/import.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/import.c b/Python/import.c index 6d014cf..d436d57 100644 --- a/Python/import.c +++ b/Python/import.c @@ -827,14 +827,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); } |
