[issue46260] Misleading SyntaxError on f-string

2022-01-05 Thread William Navaraj
William Navaraj added the comment: @Eric Smith,Thanks for explaining the intuition behind this statement. I agree. Just to avoid ambiguity we could add "f-string: unmatched '%c' - no matching open parenthesis or missing '}'" The only possibility at nested_depth==0 line 665 is either of

[issue46260] Misleading SyntaxError on f-string

2022-01-05 Thread Eric V. Smith
Eric V. Smith added the comment: No trouble. I'm glad to know it wasn't actually the same error as plain "foo)" (although the error message is the same). That would have concerned me. Changing the code so that it doesn't error out on the first problem it sees, but keeps looking for a

[issue46260] Misleading SyntaxError on f-string

2022-01-05 Thread Matt Delengowski
Matt Delengowski added the comment: Hi Eric, I see what are you referring to. Like you said unintuitive but still correct. Do you think it would be worthwhile to change the order of the checking such that '}' is always first? Or could the same edge case still appear but just the other way

[issue46260] Misleading SyntaxError on f-string

2022-01-05 Thread Eric V. Smith
Eric V. Smith added the comment: In fstring_find_expr, the code[0] that's checking for parens, braces, and brackets detects the closing paren without a matching open paren. The error message isn't incorrect: if you added a matching open paren the code would compile: >>> foo=lambda:0 >>>

[issue46260] Misleading SyntaxError on f-string

2022-01-04 Thread Eric V. Smith
Eric V. Smith added the comment: Simpler reproducer: >>> f"{foo)" File "", line 1 f"{foo)" ^ SyntaxError: f-string: unmatched ')' I assume this is the same error as: >>> foo) File "", line 1 foo) ^ SyntaxError: unmatched ')' But I don't yet understand why

[issue46260] Misleading SyntaxError on f-string

2022-01-04 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46260] Misleading SyntaxError on f-string

2022-01-04 Thread Matt Delengowski
New submission from Matt Delengowski : Example code ``` foo = 1 f"blank (open paren {foo )" ``` Error report File "", line 1 f"blank (open paren {foo )" ^ SyntaxError: f-string: unmatched ')' The problem is due to unmatched '}' however. --