Skip to content

Commit 5dbb28e

Browse files
miss-islingtonserhiy-storchaka
authored andcommitted
[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 f6e61df)
1 parent fa82dda commit 5dbb28e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix an assertion failure in `PyErr_WriteUnraisable()` in case of an
2+
exception with a bad ``__module__`` attribute. Patch by Oren Milman.

Python/errors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ PyErr_WriteUnraisable(PyObject *obj)
978978
}
979979

980980
moduleName = _PyObject_GetAttrId(t, &PyId___module__);
981-
if (moduleName == NULL) {
981+
if (moduleName == NULL || !PyUnicode_Check(moduleName)) {
982982
PyErr_Clear();
983983
if (PyFile_WriteString("<unknown>", f) < 0)
984984
goto done;

0 commit comments

Comments
 (0)