This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong position of SyntaxError in IDLE
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: terry.reedy, veky
Priority: normal Keywords:

Created on 2019-03-20 02:23 by veky, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg338432 - (view) Author: Vedran Čačić (veky) * Date: 2019-03-20 02:23
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.
msg338439 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-03-20 03:12
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.
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80557
2019-03-20 03:12:43terry.reedysetstatus: open -> closed
resolution: out of date
messages: + msg338439

stage: resolved
2019-03-20 02:24:38vekysettype: behavior
2019-03-20 02:23:57vekysetassignee: terry.reedy

nosy: + terry.reedy
components: + IDLE
versions: + Python 3.7
2019-03-20 02:23:08vekycreate