Skip to content

Commit 19aaf32

Browse files
author
neal.norwitz
committed
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__). Will backport. git-svn-id: http://svn.python.org/projects/python/trunk@53255 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 1309749 commit 19aaf32

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
1212
Core and builtins
1313
-----------------
1414

15+
- Prevent seg fault on shutdown which could occur if an object
16+
raised a warning.
17+
1518
- Bug #1566280: Explicitly invoke threading._shutdown from Py_Main,
1619
to avoid relying on atexit.
1720

Python/errors.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ PyErr_WarnEx(PyObject *category, const char *message, Py_ssize_t stack_level)
640640

641641
if (warnings_module != NULL) {
642642
dict = PyModule_GetDict(warnings_module);
643-
func = PyDict_GetItemString(dict, "warn");
643+
if (dict != NULL)
644+
func = PyDict_GetItemString(dict, "warn");
644645
}
645646
if (func == NULL) {
646647
PySys_WriteStderr("warning: %s\n", message);

0 commit comments

Comments
 (0)