[issue38508] Tracing events anomaly when creating a multi-line list

Serhiy Storchaka report at bugs.python.org
Thu Oct 17 11:26:05 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Considering the code as:

x = {
1,
2
}

It first gets constant 1.
Then gets constant 2.
Then build a set.
Then assign it to the variable.

Obviously that the variable is assigned at line 1, so you would get a backward line in any case. The set display is multiline, it occupies lines 1 to 4. What line should be reported? In many cases it is more convenient to take a first line of the multiline expression. If the building a set failed (for example if items are not hashable) you will a line "x = {" in the traceback instead of just "}".

This is not a bug, but a feature. In future perhaps tracing and traceback will get a range instead of a single line for multiline expressions, but it requires significant changes in the code.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38508>
_______________________________________


More information about the Python-bugs-list mailing list