mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
Backport:
Prevent crash on shutdown which can occur if we are finalizing and the module dict has been cleared already and some object raises a warning (like in a __del__).
This commit is contained in:
parent
1a050f5f52
commit
7770f9f6d2
2 changed files with 5 additions and 1 deletions
|
@ -640,7 +640,8 @@ PyErr_WarnEx(PyObject *category, const char *message, Py_ssize_t stack_level)
|
|||
|
||||
if (warnings_module != NULL) {
|
||||
dict = PyModule_GetDict(warnings_module);
|
||||
func = PyDict_GetItemString(dict, "warn");
|
||||
if (dict != NULL)
|
||||
func = PyDict_GetItemString(dict, "warn");
|
||||
}
|
||||
if (func == NULL) {
|
||||
PySys_WriteStderr("warning: %s\n", message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue