]> granicus.if.org Git - python/commit
bpo-37467: Fix PyErr_Display() for bytes filename (GH-14504)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 1 Jul 2019 15:11:15 +0000 (08:11 -0700)
committerGitHub <noreply@github.com>
Mon, 1 Jul 2019 15:11:15 +0000 (08:11 -0700)
commit2683ded568b24fff1139edd9127a349f432292a6
treeb7919a4b503b8e13a883579d0b3395c5e904e262
parente224d2865aa0f021b25d68de9a6c2be617341f4c
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>
Lib/test/test_sys.py
Misc/NEWS.d/next/Core and Builtins/2019-07-01-12-22-44.bpo-37467.u-XyEu.rst [new file with mode: 0644]
Python/pythonrun.c