Issue 36376: Wrong position of SyntaxError in IDLE (original) (raw)
Open IDLE, New File, put this inside:
'abcde\
')
x = 123456789
And try to Run Module. Of course, the syntax error is extra ) at the end of the second line. But it is not highlighted. What's highlighted is 123 in the third line. Some additional observations:
the length of the first line determines somehow what's highlighted in the third one: the longer the first line, more to the right the highlight goes in the third;
third line can be whatever you want, it just needs to be long enough for a highlight to appear;
you can even have blank lines between them;
the same phenomenon appears if you use triple-quoted strings instead of single-quoted with backslash line continuation.
IDLE should display the same error message and mark the error at the same spot that Python tells it too, which is to say, what is display and where it is marked when running Python in a console/terminal. The only difference is that IDLE uses red background highlight instead of a caret. For 3.7.2, IDLE displays the same 'invalid syntax' message but mis-marks the position as you say.
The latest 3.7.3rc1 and 3.8.0a2 releases on Windows, without and with IDLE, with code in file or entered interactively, correctly display "SyntaxError: unmatched ')'", with an improved message, and mark the stray ')'. The only new IDLE patch that might have fixed this (accidentally, as a side effect) was #34055. Or some detail of the info IDLE gets might have changed.
If you find another example that fails with or without IDLE, in file or at prompt, please give all details and copy and paste the traceback from both python and IDLE.
I make of note of this as a test case for a future error highlight test.