Index: Lib/traceback.py =================================================================== --- Lib/traceback.py (revision 66037) +++ Lib/traceback.py (working copy) @@ -190,7 +190,7 @@ 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