classification
Title: IDLE: Syntax Error showing pointer in wrong location
Type: enhancement Stage: resolved
Components: IDLE Versions: Python 3.9
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: epaine, steven.daprano, terry.reedy
Priority: normal Keywords:

Created on 2020-12-12 02:31 by 1051371, last changed 2020-12-12 23:42 by terry.reedy. This issue is now closed.

Messages (6)
msg382900 - (view) Author: Pratik Palwai (1051371) Date: 2020-12-12 02:31
When I get a syntax error, it shows the line with the error, and then a little '^' on the next line, showing where the error is. However, the location of the '^' is a little misleading, since it isn't in the right spot. For example (not sure if it will format correctly though):
elif self.left == None and self.right =! None:
                          ^
The symbol should be under the +! instead of under the 'and.' Also, this problem doesn't occur with the font Courier.
msg382901 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-12-12 03:23
The position of the caret assumes that every character in the string takes up the same width, measured in pixels. That is only true for monospaced fonts like Courier.

The only way to position the caret precisely with a proportional-width font is to compute the number of pixels for each character and then line up the caret at a position based on pixels rather than character columns. Unless Tkinter has functions to do both, it will probably be complicated and expensive, and I doubt anyone would care enough to do it.
msg382913 - (view) Author: E. Paine (epaine) * Date: 2020-12-12 14:19
While Tkinter could do it, I see no point in doing so. One thing that may be worth looking into is only allowing IDLE to use fixed-width fonts, but maybe this is just another of my crazy ideas... I think this can be safely closed unless someone wants to make a strong point for such changes.

@ Steven, did you mean to un-nosy Pratik?
msg382914 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-12-12 14:39
> @ Steven, did you mean to un-nosy Pratik?

No. I have tried to re-add him, but I think that because his user name 
is all digits, the bug tracker won't accept it.

When I try, I get this error:

Edit Error: user has no node 1051371
msg382925 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-12-12 23:36
Current IDLE indicates the SyntaxError position given by Python by highlighting the character, as in the editor.  No more caret.  End of problem.

There is no fixed-width Unicode font.  I revised the font sample in part to let people see which alphabets fixed in a particular font face.  Courier likely is best for this: Ascii, Latin1, IPA, Greek, Cyrillic, Hebrow, and Arabic all have the same fixed pitch, but this makes for some badly scruntched characters.

I emailed Pratik about the userid issue and the solution (upgrade).
msg382926 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-12-12 23:42
"Your message to 1051371@student.auhsd.us has been blocked. ...
This email has been rejected because it is directed outside the AUHSD domain."

Makes no sense unless the link back here was an issue.  Oh well, I tried.
History
Date User Action Args
2020-12-12 23:42:06terry.reedysetmessages: + msg382926
2020-12-12 23:36:35terry.reedysetstatus: open -> closed
title: Syntax Error showing pointer in wrong location -> IDLE: Syntax Error showing pointer in wrong location
messages: + msg382925

resolution: out of date
stage: resolved
2020-12-12 14:39:22steven.dapranosetmessages: + msg382914
2020-12-12 14:19:08epainesetnosy: + epaine
messages: + msg382913
2020-12-12 03:23:57steven.dapranosetnosy: + steven.daprano, - 1051371
messages: + msg382901
2020-12-12 02:31:431051371create