Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception name improperly indented #46951

Closed
brettcannon opened this issue Apr 26, 2008 · 7 comments
Closed

Exception name improperly indented #46951

brettcannon opened this issue Apr 26, 2008 · 7 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker

Comments

@brettcannon
Copy link
Member

BPO 2699
Nosy @brettcannon, @birkenfeld, @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/brettcannon'
closed_at = <Date 2008-04-28.03:24:19.002>
created_at = <Date 2008-04-26.23:17:37.064>
labels = ['interpreter-core', 'release-blocker']
title = 'Exception name improperly indented'
updated_at = <Date 2008-04-28.03:24:18.956>
user = 'https://github.com/brettcannon'

bugs.python.org fields:

activity = <Date 2008-04-28.03:24:18.956>
actor = 'brett.cannon'
assignee = 'brett.cannon'
closed = True
closed_date = <Date 2008-04-28.03:24:19.002>
closer = 'brett.cannon'
components = ['Interpreter Core']
creation = <Date 2008-04-26.23:17:37.064>
creator = 'brett.cannon'
dependencies = []
files = []
hgrepos = []
issue_num = 2699
keywords = []
message_count = 7.0
messages = ['65855', '65856', '65857', '65864', '65880', '65897', '65910']
nosy_count = 3.0
nosy_names = ['brett.cannon', 'georg.brandl', 'benjamin.peterson']
pr_nums = []
priority = 'release blocker'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue2699'
versions = ['Python 2.6']

@brettcannon
Copy link
Member Author

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

@brettcannon brettcannon self-assigned this Apr 26, 2008
@brettcannon brettcannon added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Apr 26, 2008
@brettcannon
Copy link
Member Author

Forgot to mention this is probably from Python/traceback.c:tb_displayline().

@benjaminp
Copy link
Contributor

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);
 }

@brettcannon
Copy link
Member Author

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.

@birkenfeld
Copy link
Member

You could add a function to the _testcapi module to invoke PyErr_Display.

@brettcannon
Copy link
Member Author

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.

@brettcannon
Copy link
Member Author

Fix in revision 62555.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants