[issue45086] f-string unmatched ']'

2021-09-04 Thread Greg Kuhn
Greg Kuhn added the comment: I see, thank you all for the detailed investigation and explanation!! Agreed Terry, anyone who reads the error should be able to parse it themselves and see what the errors is. Pointing the user to the error site is the most important piece. --

[issue45086] f-string unmatched ']'

2021-09-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: Thank you Eric. I can see now that the actual process is a somewhat complicated mix of the simple options 1 and 2 I imagined above. It is like option 2, except that everything between '{' and '}' is partially parsed enough to create a format object. This

[issue45086] f-string unmatched ']'

2021-09-04 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > But we've never gotten past just talking about it Stay tuned! :) https://github.com/we-like-parsers/cpython/tree/fstring-grammar -- ___ Python tracker

[issue45086] f-string unmatched ']'

2021-09-03 Thread Eric V. Smith
Eric V. Smith added the comment: I don't think it really makes a difference, but here's some background: For f-strings, the parser itself does not break apart the f-string into (, ) parts. There's a custom parser (at

[issue45086] f-string unmatched ']'

2021-09-03 Thread Terry J. Reedy
Terry J. Reedy added the comment: The behavior remains the same in 3.11 ('main' branch). New PEG parser parses this the same. (Pablo, if there is a mistake below, please correct.) Normally, the parser copies code chars between quotes, with or without '\' interpretation, into a string

[issue45086] f-string unmatched ']'

2021-09-02 Thread Eric V. Smith
Eric V. Smith added the comment: I think it's basically this error: >>> num] File "", line 1 num] ^ SyntaxError: unmatched ']' Although I'd have to look at it more to see why that's the error it chose to display, instead of the curly brace. --

[issue45086] f-string unmatched ']'

2021-09-02 Thread Greg Kuhn
Greg Kuhn added the comment: But doesn't the square bracket have no relevance here? It's not within a curly bracketed string so shouldn't be treated specially. I would have expected the error to be: SyntaxError: f-string: unmatched '}'. Unless I need to go back and reread pep498...

[issue45086] f-string unmatched ']'

2021-09-02 Thread Eric V. Smith
Eric V. Smith added the comment: I think the error is short for "I found a ']' without a matching '['". -- nosy: +eric.smith ___ Python tracker ___

[issue45086] f-string unmatched ']'

2021-09-02 Thread Greg Kuhn
New submission from Greg Kuhn : Hi All, Is the below a bug? Shouldn't the interpreter be complaining about a curly brace? $ python Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more