[Python-ideas] Make traceback messages aware of line continuation
Terry Jan Reedy
tjreedy at udel.edu
Tue Apr 30 02:40:37 CEST 2013
On 4/29/2013 1:42 PM, Giampaolo Rodola' wrote:
> 2013/4/29 Giampaolo Rodola' <g.rodola at gmail.com>:
>> Consider the following:
>>
>> assert \
>> 1 == 0, \
>> "error"
>>
>> It will produce:
>>
>> Traceback (most recent call last):
>> File "foo.py", line 3, in <module>
>> "error"
>> AssertionError: error
>>
>> The information about the statement which produced the exception is lost.
>> Instead I would expect:
>>
>> Traceback (most recent call last):
>> File "foo.py", line 1, in <module>
>> assert \
>> 1 == 0, \
>> "error"
>> AssertionError: error
>>
>>
>> Not sure how easy this is to implement but I think it would be a good
>> enhancement.
>> Thoughts?
Very dubious idea, for multiple reasons given on the issue.
> It seems this is already tracked in http://bugs.python.org/issue12458
For your example, the OP of that issue would replace the line '"error"'
with 'assert', which would not be helpful at all. If your statement was
assert some_fairly_long_expression_with_calls ==\
something_else, "error"
then is would not be clear that backing up would be helpful.
Terry
More information about the Python-ideas
mailing list