]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.6] bpo-31418: Fix an assertion failure in PyErr_WriteUnraisable() in case of an...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 14 Sep 2017 06:41:39 +0000 (23:41 -0700)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 14 Sep 2017 06:41:39 +0000 (09:41 +0300)
(cherry picked from commit f6e61df01536493f1280cd07639c7ff9bffb2cdc)

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 60958438152afa8445cd0ee4ebb1760f227b6154..2f39f9d473db2050b21cac33c6d6c44beeceb9f3 100644 (file)
@@ -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("<unknown>", f) < 0)
             goto done;