mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
bpo-31418: Fix an assertion failure in PyErr_WriteUnraisable() in case of an exception with a bad __module__ attribute. (#3539)
This commit is contained in:
parent
ace1ecc00b
commit
f6e61df015
2 changed files with 3 additions and 1 deletions
|
@ -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.
|
|
@ -961,7 +961,7 @@ PyErr_WriteUnraisable(PyObject *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
moduleName = _PyObject_GetAttrId(t, &PyId___module__);
|
moduleName = _PyObject_GetAttrId(t, &PyId___module__);
|
||||||
if (moduleName == NULL) {
|
if (moduleName == NULL || !PyUnicode_Check(moduleName)) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
if (PyFile_WriteString("<unknown>", f) < 0)
|
if (PyFile_WriteString("<unknown>", f) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue