Message368473
@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!
@Lysandros:
I wonder if this is the fix we're looking for?
diff --git a/Lib/traceback.py b/Lib/traceback.py
index bf34bbab8a..0e286f60bc 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -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:57 | gvanrossum | set | recipients:
+ gvanrossum, terry.reedy, lys.nikolaou, pablogsal, BTaskaya |
2020-05-08 21:55:57 | gvanrossum | set | messageid: <1588974957.28.0.529964316833.issue40546@roundup.psfhosted.org> |
2020-05-08 21:55:57 | gvanrossum | link | issue40546 messages |
2020-05-08 21:55:56 | gvanrossum | create | |
|