[issue17825] Indentation.offset and SyntaxError.offset mismatch

Terry J. Reedy report at bugs.python.org
Fri Apr 26 23:58:17 CEST 2013


Terry J. Reedy added the comment:

Perhaps Florent is pointing to the fact that for 'except X:', the syntax error is detected at the ' ' at offset 6 but the caret is backed up under the 't' at offset 5*, whereas it is not backed up to the space before '    open'. Which behavior do you propose to change?

Since these details of presentation are not documented, I do not consider the current difference a bug. I would not change them in current versions since change could confuse people or software. I suspect there is also danger of making some cases worse. For the same reasons, I would not change in future versions either without good offsetting reason. So I also think this should be closed.

On python-list, we tell people that the caret is a starting point for detecting the error, not an absolute pointer.

For syntax errors, Idle omits the traceback and highlights in red the presumed error. For the first, it marks the entire word 'except'. For the second, it marks the last whitespace before open. This is equivalent to backing up the caret.

* I suspect this backup is special to keywords. For 'except+', both systems also mark the keyword, not the '+'. Either the keyword is misused or is a regular name misspelled. In either case, someone thought it better to point to the keyword than the space or other character after. I agree. So did the Idle author who decided to highlight the keyword rather than the character after it.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17825>
_______________________________________


More information about the Python-bugs-list mailing list