The code that computes the lines is already quite complex (to the point that has to do some AST analysis and post-parsing) so I am quite worried to introduce a lot of complexity in this area. I am fine doing something that we can easily check for (spawns all the line) but I would be against having to start doing even more analysis (especially for things that are not AST-based).

Take into account that code that displays exceptions need to be very resilient because it can be called in some tricky situations and validating that all the code works correctly is very hard, and complex to maintain.

As I said, I think I would be supportive of considering adding a check for the full line, but I think that adding more complexity here is quite dangerous.

On Tue, 18 Jan 2022 at 21:49, Patrick Reader <_@pxeger.com> wrote:
On 18/01/2022 20:41, Pablo Galindo Salgado wrote:
We cannot base the computation on a % because is possible that the location markers are relevant
but the variables, function names or constructs are just very large. I think that the idea of "spawns
the whole line" is sensible, though.

On Tue, 18 Jan 2022 at 20:32, Steve Dower <steve.dower@python.org> wrote:

Omitting the line of ^ where over x% (75%? 90%?) of characters on the
line would be marked would be fine by me.

It would also need to take into account cases where a line contains an inline comment, which does not contribute to the code producing the error, but where all of the rest of the line (the code) is the source of the error and highlighting it is not useful

# test.py:

code_that_causes_an_error # a comment

$ python3.11 test.py

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    code_that_causes_an_error # a comment
    ^^^^^^^^^^^^^^^^^^^^^^^^^
NameError: name 'code_that_causes_an_error' is not defined

(the traceback shown is from a current `main` build)

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/F4FSJY7OIPHAH5I6YBHCFI4DP3XLNUJW/
Code of Conduct: http://python.org/psf/codeofconduct/