On 7/31/2019 11:19 PM, jsals...@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:

print(1/)
   File "<stdin>", line 1
     print(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

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to