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.

Author terry.reedy
Recipients Alex-Python-Programmer, terry.reedy
Date 2020-04-27.00:57:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587949053.39.0.706385310107.issue40384@roundup.psfhosted.org>
In-reply-to
Content
For me, on Mac, only  the 3rd 'def', on line 4, changes to blue, the default highlight for defined names (those immediately following 'def' or 'class').  This is because deleting the '#' causes recoloring from there onward, and IDLE's handling of newlines after 'def' or 'class' is buggy. I presume that you see the same.

I most concerned with correctly highlighting correct code.  It may be ambiguous what to do with incorrect code.  If one types 'def name' or 'class name' to start a line, name is colored blue as a definition name.  If name happens to be misspelled to match a keyword, should it be colored as a keyword?  Maybe, but in this context, it will not function as such.  Perhaps it should be immediately colored as a syntax error (default red), instead of waiting for an explicit syntax check.  But this an innovation for IDLE and should be a different issue from this one.

If there is a newline between def/class and the name, python sees it as a space if escaped with '\' but a syntax error if not.  IDLE effectively does the opposite.  The idprog in idlelib.colorizer uses \s, which matches a bare newline, among other things, but not 'backslash newline'.    I intend to replace '\s' with alternatives legal in this context.

def\
name ...  # Name should be blue, at least after multiline recolor.

def
name ...  # 'def\n' is error; name should not be blue ever.
History
Date User Action Args
2020-04-27 00:57:33terry.reedysetrecipients: + terry.reedy, Alex-Python-Programmer
2020-04-27 00:57:33terry.reedysetmessageid: <1587949053.39.0.706385310107.issue40384@roundup.psfhosted.org>
2020-04-27 00:57:33terry.reedylinkissue40384 messages
2020-04-27 00:57:32terry.reedycreate