]> granicus.if.org Git - python/commitdiff
#3584: ignore trailing newlines when placing the caret for a SyntaxError location.
authorGeorg Brandl <georg@python.org>
Thu, 4 Jun 2009 09:15:12 +0000 (09:15 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 4 Jun 2009 09:15:12 +0000 (09:15 +0000)
Lib/traceback.py

index 86a2c06b3c50730b393ea10e8433435c3d1875a1..8d28afc0cd00800cab8fa56fdece9af4c8d02296 100644 (file)
@@ -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