Message188133
I think all the lines involved in a multi-line expression should be reported.
Take for example this simple code:
x = [int(c, 16)
for c in '0123456789ABCDEFG'
if c.isdigit() or c.isupper()]
With Python 2 the traceback is:
Traceback (most recent call last):
File "deleteme.py", line 3, in <module>
if c.isdigit() or c.isupper()]
ValueError: invalid literal for int() with base 16: 'G'
Which is not very helpful, because you don't see the int() call that is causing the error in the first place and you don't see where the G comes from.
Incidentally, for this specific case, the traceback is a bit better on Python3:
Traceback (most recent call last):
File "deleteme.py", line 2, in <module>
for c in '0123456789ABGDEF'
File "deleteme.py", line 3, in <listcomp>
if c.isdigit() or c.isupper()]
ValueError: invalid literal for int() with base 16: 'G'
But this still misses the int() call.
IMHO it would be better to have something like:
Traceback (most recent call last):
File "deleteme.py", lines 1-3, in <module>
x = [int(c, 16)
for c in '0123456789ABCDEFG'
if c.isdigit() or c.isupper()]
ValueError: invalid literal for int() with base 16: 'G'
If this is rejected for some reason, I think printing the first line -- rather than the last -- would still be an improvement, because in most of the cases the first line contains more information (e.g. the name of the function with a multi-line list of args, a raise/assert with the name of the exception and part of the message, the operation done for each element of a genexp/listcomp). |
|
Date |
User |
Action |
Args |
2013-04-30 07:12:22 | ezio.melotti | set | recipients:
+ ezio.melotti, georg.brandl, terry.reedy, ncoghlan, giampaolo.rodola, psss, flox, lesmana, petri.lehtinen, icordasc |
2013-04-30 07:12:22 | ezio.melotti | set | messageid: <1367305942.02.0.480726829877.issue12458@psf.upfronthosting.co.za> |
2013-04-30 07:12:22 | ezio.melotti | link | issue12458 messages |
2013-04-30 07:12:21 | ezio.melotti | create | |
|