This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Exception name improperly indented
Type: Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: barry, benjamin.peterson, brett.cannon, georg.brandl
Priority: release blocker Keywords:

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 "<stdin>", line 1, in <module>
  KeyError

not::

  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
      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:33adminsetnosy: + barry
github: 46951
2008-04-28 03:24:19brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg65910
2008-04-27 20:04:24brett.cannonsetmessages: + msg65897
2008-04-27 09:34:11georg.brandlsetnosy: + georg.brandl
messages: + msg65880
2008-04-27 01:24:55brett.cannonsetmessages: + msg65864
2008-04-26 23:53:17benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg65857
2008-04-26 23:19:07brett.cannonsetmessages: + msg65856
2008-04-26 23:17:37brett.cannoncreate