From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 14 Sep 2017 06:41:39 +0000 (-0700) Subject: [3.6] bpo-31418: Fix an assertion failure in PyErr_WriteUnraisable() in case of an... X-Git-Tag: v3.6.3rc1~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5dbb28ececdd0382d85b164aaf37bec1ae08036c;p=thirdparty%2FPython%2Fcpython.git [3.6] bpo-31418: Fix an assertion failure in PyErr_WriteUnraisable() in case of an exception with a bad __module__ attribute. (GH-3539) (#3556) (cherry picked from commit f6e61df01536493f1280cd07639c7ff9bffb2cdc) --- diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-09-13-13-03-52.bpo-31418.rS-FlC.rst b/Misc/NEWS.d/next/Core and Builtins/2017-09-13-13-03-52.bpo-31418.rS-FlC.rst new file mode 100644 index 000000000000..6d6cbd811420 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2017-09-13-13-03-52.bpo-31418.rS-FlC.rst @@ -0,0 +1,2 @@ +Fix an assertion failure in `PyErr_WriteUnraisable()` in case of an +exception with a bad ``__module__`` attribute. Patch by Oren Milman. diff --git a/Python/errors.c b/Python/errors.c index 60958438152a..2f39f9d473db 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -978,7 +978,7 @@ PyErr_WriteUnraisable(PyObject *obj) } moduleName = _PyObject_GetAttrId(t, &PyId___module__); - if (moduleName == NULL) { + if (moduleName == NULL || !PyUnicode_Check(moduleName)) { PyErr_Clear(); if (PyFile_WriteString("", f) < 0) goto done;