Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDLE: fix highlight locationfor f-string field errors #87766

Closed
terryjreedy opened this issue Mar 23, 2021 · 2 comments
Closed

IDLE: fix highlight locationfor f-string field errors #87766

terryjreedy opened this issue Mar 23, 2021 · 2 comments
Assignees
Labels
3.10 only security fixes 3.11 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

terryjreedy commented Mar 23, 2021

BPO 43600
Nosy @terryjreedy

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/terryjreedy'
closed_at = None
created_at = <Date 2021-03-23.02:03:51.083>
labels = ['expert-IDLE', 'type-bug', '3.8', '3.9', '3.10']
title = 'IDLE: fix highlight locationfor f-string field errors'
updated_at = <Date 2021-03-23.02:03:51.083>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2021-03-23.02:03:51.083>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = False
closed_date = None
closer = None
components = ['IDLE']
creation = <Date 2021-03-23.02:03:51.083>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 43600
keywords = []
message_count = 1.0
messages = ['389365']
nosy_count = 1.0
nosy_names = ['terry.reedy']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'test needed'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue43600'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

Linked PRs

@terryjreedy
Copy link
Member Author

Spinoff from bpo-41064. In current python, the f'{*x}' traceback ends with

(*x)
 ^

SyntaxError: f-string: can't use starred expression here.

For f'{**x}', the message is "f-string: invalid syntax" and the ^ is also under the 2nd character in the replacement expression actually parsed (with a restricted grammar).

The Python error handler must special case a syntax error message beginning with 'f-string:' and search the input line for {...} and add its offset.

IDLE currently highlights "'", the 2nd char of the original code, instead of '*', the 2nd char of the e.text replacement. It needs to also adjust the offset.

@terryjreedy terryjreedy added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes labels Mar 23, 2021
@terryjreedy terryjreedy self-assigned this Mar 23, 2021
@terryjreedy terryjreedy added 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error 3.9 only security fixes 3.10 only security fixes labels Mar 23, 2021
@terryjreedy terryjreedy self-assigned this Mar 23, 2021
@terryjreedy terryjreedy added topic-IDLE type-bug An unexpected behavior, bug, or error labels Mar 23, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@terryjreedy terryjreedy added 3.11 only security fixes and removed 3.9 only security fixes 3.8 only security fixes labels Mar 28, 2024
@terryjreedy
Copy link
Member Author

This bug continued in 3.11. In 3.12, the parsing of f-strings was completely revised to be part of normal parsing instead of separate. 3.13.a5+ shows:

>>> f'{*x}'
  File "<stdin>-0", line 1
SyntaxError: can't use starred expression here

and IDLE shows the same message without the File... line and with * properly highlighted. Since the patch did not work for me and would benefit very few, I close this issue.

@terryjreedy terryjreedy closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
Projects
Status: Done
Development

No branches or pull requests

1 participant