mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
gh-108082: Use PyErr_FormatUnraisable() (GH-111580)
Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable(). Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
a12f624a9d
commit
970e719a7a
18 changed files with 83 additions and 114 deletions
|
|
@ -584,7 +584,7 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
|
|||
if (PyList_SetSlice(MODULES_BY_INDEX(interp),
|
||||
0, PyList_GET_SIZE(MODULES_BY_INDEX(interp)),
|
||||
NULL)) {
|
||||
PyErr_WriteUnraisable(MODULES_BY_INDEX(interp));
|
||||
PyErr_FormatUnraisable("Exception ignored on clearing interpreters module list");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3156,13 +3156,13 @@ _PyImport_FiniCore(PyInterpreterState *interp)
|
|||
int verbose = _PyInterpreterState_GetConfig(interp)->verbose;
|
||||
|
||||
if (_PySys_ClearAttrString(interp, "meta_path", verbose) < 0) {
|
||||
PyErr_WriteUnraisable(NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored on clearing sys.meta_path");
|
||||
}
|
||||
|
||||
// XXX Pull in most of finalize_modules() in pylifecycle.c.
|
||||
|
||||
if (_PySys_ClearAttrString(interp, "modules", verbose) < 0) {
|
||||
PyErr_WriteUnraisable(NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored on clearing sys.modules");
|
||||
}
|
||||
|
||||
if (IMPORT_LOCK(interp) != NULL) {
|
||||
|
|
@ -3242,10 +3242,10 @@ _PyImport_FiniExternal(PyInterpreterState *interp)
|
|||
// XXX Uninstall importlib metapath importers here?
|
||||
|
||||
if (_PySys_ClearAttrString(interp, "path_importer_cache", verbose) < 0) {
|
||||
PyErr_WriteUnraisable(NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored on clearing sys.path_importer_cache");
|
||||
}
|
||||
if (_PySys_ClearAttrString(interp, "path_hooks", verbose) < 0) {
|
||||
PyErr_WriteUnraisable(NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored on clearing sys.path_hooks");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue