Issue 29071: IDLE doesn't highlight f-strings properly (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/73257

classification

Title: IDLE doesn't highlight f-strings properly
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.7, Python 3.6

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Kenzie Togami, ammar2, python-dev, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2016-12-26 01:16 by Kenzie Togami, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python_idle_3.6_bug.png Kenzie Togami,2016-12-26 01:16 Screenshot of f- and r- strings in IDLE
idle-f-string-highlight.diff ammar2,2016-12-26 23:38 review
Messages (11)
msg284010 - (view) Author: Kenzie Togami (Kenzie Togami) Date: 2016-12-26 01:16
IDLE doesn't highlight f-strings like r-strings or u-strings. See the attached screenshot.
msg284051 - (view) Author: Ammar Askar (ammar2) * (Python committer) Date: 2016-12-26 23:38
I've attached a patch that colorizes f-strings. The issue is marked as "test needed" which the dev guide says "... reporter should post a script or instructions to let a triager or developer reproduce the issue." Steps to re-create are to open an IDLE window and type in the code ``` f"123" F"123" u"123" ``` and notice the colorization difference.
msg284062 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-12-27 05:05
New changeset a48cc85e5706 by Terry Jan Reedy in branch '3.6': Issue #29071: IDLE now colors f-string prefixes (but not invalid ur prefixes). https://hg.python.org/cpython/rev/a48cc85e5706
msg284064 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-12-27 05:20
There are 10 possible f-string prefixes, including combinations with r/R. See https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals While adding these, I noticed that IDLE was coloring now invalid ur prefixes and deleted those. I decided to test by modifying the existing human visual htest. Ammar: thank you for submitting a patch. It happens that I wrote my patch before I saw your submission. If I had seen yours first, I might have given you a chance to finish it. Feel free to try another IDLE issue.
msg284065 - (view) Author: Ammar Askar (ammar2) * (Python committer) Date: 2016-12-27 05:44
Not a problem, thank you for the encouragement.
msg284420 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-01 06:35
The regular expression can be simplified using local flags: - stringprefix = (r"(\br|R u U
msg284439 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017-01-02 02:22
New changeset 62d3c0336df6 by Terry Jan Reedy in branch '3.6': Issue #29071: Use local flags for IDLE colorizer string prefix matcher. https://hg.python.org/cpython/rev/62d3c0336df6
msg284440 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-01-02 02:24
Thank you for the new feature (I presume) and its application. I disliked both writing and reading all the near duplication. I am posting this to python-list as an example of what the new feature is good for.
msg284472 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-02 07:06
Thank you for advertising the new feature. Would you like to improve the documentation? It always was the hardest part to me.
msg284479 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-01-02 12:34
The doc appears to be carefully accurate, but the second sentence especially is a bit awkward. I will open a new issue.
msg291284 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-04-07 18:30
#29287 is about syntax highlighting the code within f-strings as code rather than as part of the string.
History
Date User Action Args
2022-04-11 14:58:41 admin set github: 73257
2017-04-07 18:30:17 terry.reedy set messages: +
2017-01-02 12:34:52 terry.reedy set messages: +
2017-01-02 07:06:47 serhiy.storchaka set messages: +
2017-01-02 02:24:52 terry.reedy set messages: +
2017-01-02 02:22:10 python-dev set messages: +
2017-01-01 06:35:59 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2016-12-27 05:44:40 ammar2 set messages: +
2016-12-27 05:20:10 terry.reedy set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2016-12-27 05:05:58 python-dev set nosy: + python-devmessages: +
2016-12-26 23:38:36 ammar2 set files: + idle-f-string-highlight.diffnosy: + ammar2messages: + keywords: + patchstage: test needed -> patch review
2016-12-26 07:15:00 terry.reedy set stage: test neededversions: + Python 3.7
2016-12-26 01:16:18 Kenzie Togami create