mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Move f-string compilation of the expression earlier, before the conversion character and format_spec are checked. This allows for error messages that more closely match what a user would expect.
This commit is contained in:
parent
3a1a8d0424
commit
1d44c41b0c
2 changed files with 60 additions and 15 deletions
|
@ -287,6 +287,15 @@ f'{a * x()}'"""
|
|||
"f' { } '",
|
||||
r"f'{\n}'",
|
||||
r"f'{\n \n}'",
|
||||
|
||||
# Catch the empty expression before the
|
||||
# invalid conversion.
|
||||
"f'{!x}'",
|
||||
"f'{ !xr}'",
|
||||
"f'{!x:}'",
|
||||
"f'{!x:a}'",
|
||||
"f'{ !xr:}'",
|
||||
"f'{ !xr:a}'",
|
||||
])
|
||||
|
||||
def test_parens_in_expressions(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue