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
|
@ -12,6 +12,9 @@ What's New in Python 2.5.1c1?
|
|||
Core and builtins
|
||||
-----------------
|
||||
|
||||
- Prevent seg fault on shutdown which could occur if an object
|
||||
raised a warning.
|
||||
|
||||
- Bug #1566280: Explicitly invoke threading._shutdown from Py_Main,
|
||||
to avoid relying on atexit.
|
||||
|
||||
|
|
|
@ -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…
Reference in New Issue