TL;DR include multiple lines in traceback when appropriate (expressions broken up over multiple lines) to make it easier to spot error from looking at traceback
Apologies if this has been suggested/discussed before. I am suggesting that if you do:
```
[
x for x in 0
]
```
the traceback will be:
```
Traceback (most recent call last):
File "foo.py", line 1-3, in <module>
[
x for x in 0
]
TypeError: 'int' object is not iterable
```
instead of the current
```
Traceback (most recent call last):
File "foo.py", line 1, in <module>
[
TypeError: 'int' object is not iterable
```
Similarly for when an operator is applied over different lines:
```
(
0 &
"world"
)
```
would lead to
```
Traceback (most recent call last):
File "foo.py", line 2-3, in <module>
0 &
"world"
TypeError: unsupported operand type(s) for &: 'int' and 'str'
```
instead of
```
Traceback (most recent call last):
File "foo.py", line 2-3, in <module>
"hello" &
TypeError: unsupported operand type(s) for &: 'int' and 'str'
```
Traceback (most recent call last):
File "foo.py", line 1-4, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'foor'
I don't think this change would rock the world, but I think it is a nice quality-of-life improvement that would ease debugging. In particular the last example (open function call) showcases how it can make easier to spot a bug, especially if it is to do with how the expression is broken up
What do people think? Any particular reason this is not possible or done? I'm guessing it would require quite a bit of restructuring in the traceback object/module and potentially have backwards compatibility implications.