diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-07-01 15:11:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-01 15:11:15 (GMT) |
commit | 2683ded568b24fff1139edd9127a349f432292a6 (patch) | |
tree | b7919a4b503b8e13a883579d0b3395c5e904e262 /Python/pythonrun.c | |
parent | e224d2865aa0f021b25d68de9a6c2be617341f4c (diff) | |
download | cpython-2683ded568b24fff1139edd9127a349f432292a6.zip cpython-2683ded568b24fff1139edd9127a349f432292a6.tar.gz cpython-2683ded568b24fff1139edd9127a349f432292a6.tar.bz2 |
bpo-37467: Fix PyErr_Display() for bytes filename (GH-14504)
Fix sys.excepthook() and PyErr_Display() if a filename is a bytes
string. For example, for a SyntaxError exception where the filename
attribute is a bytes string.
Cleanup also test_sys:
* Sort imports.
* Rename numruns global var to INTERN_NUMRUNS.
* Add DisplayHookTest and ExceptHookTest test case classes.
* Don't save/restore sys.stdout and sys.displayhook using
setUp()/tearDown(): do it in each test method.
* Test error case (call hook with no argument) after the success case.
(cherry picked from commit f9b7457bd7f438263e0d2dd1f70589ad56a2585e)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 8f3ee19..f1d946a 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -797,7 +797,7 @@ print_exception(PyObject *f, PyObject *value) Py_DECREF(value); value = message; - line = PyUnicode_FromFormat(" File \"%U\", line %d\n", + line = PyUnicode_FromFormat(" File \"%S\", line %d\n", filename, lineno); Py_DECREF(filename); if (line != NULL) { |