[issue37467] sys.excepthook (PyErr_Display) does crash with SyntaxError which has a bytes filename

STINNER Victor report at bugs.python.org
Mon Jul 1 10:57:01 EDT 2019


STINNER Victor <vstinner at redhat.com> added the comment:

Python 2.7 is not affected:

            const char *filename, *text;
            int lineno, offset;
            if (!parse_syntax_error(value, &message, &filename,
                                    &lineno, &offset, &text))
                PyErr_Clear();
            else {
                char buf[10];
                PyFile_WriteString("  File \"", f);
                if (filename == NULL)
                    PyFile_WriteString("<string>", f);
                else
                    PyFile_WriteString(filename, f);
                PyFile_WriteString("\", line ", f);
                PyOS_snprintf(buf, sizeof(buf), "%d", lineno);
                PyFile_WriteString(buf, f);
                PyFile_WriteString("\n", f);

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37467>
_______________________________________


More information about the Python-bugs-list mailing list