Issue 23687: Stacktrace identifies wrong line in multiline list comprehension
This code:
z = [
["Y" for y in None
] for x in range(4)
]
produces this stacktrace in both Python 2.7 and 3.4:
Traceback (most recent call last):
File "/Users/edwsmith/dev/untitled4/test.py", line 7, in <module>
] for x in range(4)
File "/Users/edwsmith/dev/untitled4/test.py", line 7, in <listcomp>
] for x in range(4)
TypeError: 'NoneType' object is not iterable
Of course my code was slightly more complex, but I lost a fair amount of time troubleshooting how the 'for x in range(4)' was evaluating to None, when really, it was the inner comprehension that was failing.
Ideally the stack trace would say:
Traceback (most recent call last):
File "/Users/edwsmith/dev/untitled4/test.py", line 6, in <module>
["Y" for y in None
File "/Users/edwsmith/dev/untitled4/test.py", line 6, in <listcomp>
["Y" for y in None
TypeError: 'NoneType' object is not iterable