From eb56aa169a7af96254118fc47aa37df1da023987 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 4 Jun 2009 09:15:12 +0000 Subject: #3584: ignore trailing newlines when placing the caret for a SyntaxError location. --- Lib/traceback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/traceback.py b/Lib/traceback.py index 86a2c06..8d28afc 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -189,7 +189,7 @@ def format_exception_only(etype, value): if badline is not None: lines.append(' %s\n' % badline.strip()) if offset is not None: - caretspace = badline[:offset].lstrip() + caretspace = badline.rstrip('\n')[:offset].lstrip() # non-space whitespace (likes tabs) must be kept for alignment caretspace = ((c.isspace() and c or ' ') for c in caretspace) # only three spaces to account for offset1 == pos 0 -- cgit v0.12