Why won't the run-time error reporter point to the error position with a caret like the syntax error reporter does? It knows exactly where the error is.
On 7/31/2019 11:19 PM, jsalsman at gmail.com wrote:
> Honestly this is the only thing in over half a decade of daily python use which has disappointed me enough to want to ask the devs:
> File "<stdin>", line 1
> SyntaxError: invalid syntax
SyntaxErrors mostly come from the parser, occasionally from the
compiler, both of which have access to line and column.
>>>> print(1/1, 1/0, 1/1)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ZeroDivisionError: division by zero
This comes from the runtime engine, which only has access to line
numbers, and even line numbers lie when a statement spans multiple
lines. In CPython, the runtime engine is executing bytecodes, and
bytecode do not correspond to column numbers. In something like
"a + b / (2 * c + d//3)", if the denominator (which could be on multiple
lines) is 0, where should a caret point?
Terry Jan Reedy