]> granicus.if.org Git - python/commitdiff
bpo-31418: Fix an assertion failure in PyErr_WriteUnraisable() in case of an exceptio...
authorOren Milman <orenmn@gmail.com>
Wed, 13 Sep 2017 22:30:05 +0000 (01:30 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 13 Sep 2017 22:30:05 +0000 (01:30 +0300)
Misc/NEWS.d/next/Core and Builtins/2017-09-13-13-03-52.bpo-31418.rS-FlC.rst [new file with mode: 0644]
Python/errors.c

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 (file)
index 0000000..6d6cbd8
--- /dev/null
@@ -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.
index 3cb6d5306f81d9f33a969b1d6be12480b3c81fe5..5709fddb58411516b13989a085005f90a6194620 100644 (file)
@@ -961,7 +961,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("<unknown>", f) < 0)
             goto done;