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 brodie
Recipients brodie
Date 2008-08-26.02:30:22
SpamBayes Score 1.7622903e-11
Marked as misclassified No
Message-id <1219717826.16.0.00104451287551.issue3684@psf.upfronthosting.co.za>
In-reply-to
Content
>> +
  File "<stdin>", line 1
    +
    ^
SyntaxError: invalid syntax
>>> import sys
>>> import traceback
>>> traceback.print_exception(sys.last_type, sys.last_value, None)
  File "<stdin>", line 1
     +
     
^
 SyntaxError: invalid syntax
>>> sys.last_value
SyntaxError('invalid syntax', ('<stdin>', 1, 2, '+\n'))

print_error_text() effectively ignores trailing newlines when placing 
the caret, while traceback.format_exception_only() does not. For certain 
syntax errors the offset reported is sometimes at the newline, as in the 
case of a line of code that ends just with a plus sign (and in other 
similar cases).

I'm attaching a patch for trunk that fixes this issue. I know it also 
affects Python 2.5, and I'm sure it affects versions prior. I don't know 
about Python 3.0.
History
Date User Action Args
2008-08-26 02:30:26brodiesetrecipients: + brodie
2008-08-26 02:30:26brodiesetmessageid: <1219717826.16.0.00104451287551.issue3684@psf.upfronthosting.co.za>
2008-08-26 02:30:24brodielinkissue3684 messages
2008-08-26 02:30:24brodiecreate