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.

Author gvanrossum
Recipients BTaskaya, gvanrossum, lys.nikolaou, pablogsal, terry.reedy
Date 2020-05-08.21:55:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
@Terry: Thanks for confirming the bug in the old parser.

Regarding whether column offsets should be 0-based or 1-based: I agree with Tk, but my hand was forced for SyntaxError: we found that it was already using 1-based offsets and we found correct-looking code elsewhere that depended on this, so we had to change the few cases where it was using 0-based offsets, alas.

I think I also looked at how vim and Emacs interpret column numbers, and found that both expect 1-based offsets in compiler error messages of the form "file:line:col: message". IIRC I had to do a deep-dive on this subject when we added column offsets to mypy error messages.

But it's a pain!


I wonder if this is the fix we're looking for?

diff --git a/Lib/ b/Lib/
index bf34bbab8a..0e286f60bc 100644
--- a/Lib/
+++ b/Lib/
@@ -582,7 +582,7 @@ class TracebackException:
             yield '    {}\n'.format(badline.strip())
             if offset is not None:
                 caretspace = badline.rstrip('\n')
-                offset = min(len(caretspace), offset) - 1
+                offset = min(len(caretspace) + 1, offset) - 1
                 caretspace = caretspace[:offset].lstrip()
                 # non-space whitespace (likes tabs) must be kept for alignment
                 caretspace = ((c.isspace() and c or ' ') for c in caretspace)
Date User Action Args
2020-05-08 21:55:57gvanrossumsetrecipients: + gvanrossum, terry.reedy, lys.nikolaou, pablogsal, BTaskaya
2020-05-08 21:55:57gvanrossumsetmessageid: <>
2020-05-08 21:55:57gvanrossumlinkissue40546 messages
2020-05-08 21:55:56gvanrossumcreate