Issue 2699: Exception name improperly indented (original) (raw)

Created on 2008-04-26 23:17 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg65855 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-04-26 23:17
The new warnings implementation tweaks how tracebacks are printed. This introduced a bug where the exception name is indented when it shouldn't be: e.g., ``raise KeyError`` should look like:: Traceback (most recent call last): File "", line 1, in KeyError not:: Traceback (most recent call last): File "", line 1, in KeyError
msg65856 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-04-26 23:19
Forgot to mention this is probably from Python/traceback.c:tb_displayline().
msg65857 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-04-26 23:53
It looks like you can just remove the offending line like so: Index: Python/traceback.c =================================================================== --- Python/traceback.c (revision 62515) +++ Python/traceback.c (working copy) @@ -222,8 +222,7 @@ err = PyFile_WriteString(linebuf, f); if (err != 0) return err; - - err = PyFile_WriteString(" ", f); + return Py_DisplaySourceLine(f, filename, lineno); }
msg65864 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-04-27 01:24
Yep. I already did that and ran the unit test suite to verify. Now I am just trying to figure out how to best test it. It seems it only comes up for printing a traceback. That would mean either using subprocess to run another interpreter and capture its output or cheat and use ctypes. I don't like either solution.
msg65880 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-04-27 09:34
You could add a function to the _testcapi module to invoke PyErr_Display.
msg65897 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-04-27 20:04
On Sun, Apr 27, 2008 at 2:34 AM, Georg Brandl <report@bugs.python.org> wrote: > > Georg Brandl <georg@python.org> added the comment: > > You could add a function to the _testcapi module to invoke PyErr_Display. > That's true and probably the only sane idea.
msg65910 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-04-28 03:24
Fix in revision 62555.
History
Date User Action Args
2022-04-11 14:56:33 admin set nosy: + barrygithub: 46951
2008-04-28 03:24:19 brett.cannon set status: open -> closedresolution: fixedmessages: +
2008-04-27 20:04:24 brett.cannon set messages: +
2008-04-27 09:34:11 georg.brandl set nosy: + georg.brandlmessages: +
2008-04-27 01:24:55 brett.cannon set messages: +
2008-04-26 23:53:17 benjamin.peterson set nosy: + benjamin.petersonmessages: +
2008-04-26 23:19:07 brett.cannon set messages: +
2008-04-26 23:17:37 brett.cannon create