[Python-checkins] bpo-31418: Fix an assertion failure in PyErr_WriteUnraisable() in case of an exception with a bad __module__ attribute. (#3539)
Serhiy Storchaka
webhook-mailer at python.org
Wed Sep 13 18:30:08 EDT 2017
https://github.com/python/cpython/commit/f6e61df01536493f1280cd07639c7ff9bffb2cdc
commit: f6e61df01536493f1280cd07639c7ff9bffb2cdc
branch: master
author: Oren Milman <orenmn at gmail.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2017-09-14T01:30:05+03:00
summary:
bpo-31418: Fix an assertion failure in PyErr_WriteUnraisable() in case of an exception with a bad __module__ attribute. (#3539)
files:
A Misc/NEWS.d/next/Core and Builtins/2017-09-13-13-03-52.bpo-31418.rS-FlC.rst
M 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
index 00000000000..6d6cbd81142
--- /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 3cb6d5306f8..5709fddb584 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -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;
More information about the Python-checkins
mailing list