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
Inaccurate error message for f-string #79675
Labels
3.8
only security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-feature
A feature request or enhancement
Comments
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> spam = 'spam'
>>> f'{spam[0}'
File "<stdin>", line 1
SyntaxError: f-string: expecting '}' The error message seems wrong because a "]" is missing rather than a "}". |
I can take this issue if you do not mind. |
Go ahead, Serhiy. Thanks! |
The same behavior applies to f'{spam[}' and f'{spam(}'. Also to f'{spam{}', but that might be expected. This message is more clear:
>>> f'{spam('
File "<stdin>", line 1
SyntaxError: f-string: mismatched '(', '{', or '[' Perhaps you want to apply that to the above error cases. Then you wouldn't have to catch any type of bracket. :-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.8
only security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-feature
A feature request or enhancement
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: