diff options
author | Eric V. Smith <eric@trueblade.com> | 2015-09-23 11:49:00 (GMT) |
---|---|---|
committer | Eric V. Smith <eric@trueblade.com> | 2015-09-23 11:49:00 (GMT) |
commit | 1d44c41b0cc183603b31ac943ef452456bef089f (patch) | |
tree | 7b8dcbf17ff2c20b6e9adc7c581305668ef9ff70 /Lib/test/test_fstring.py | |
parent | 3a1a8d04244cb5d98e8bbeaff131a705f84b8521 (diff) | |
download | cpython-1d44c41b0cc183603b31ac943ef452456bef089f.zip cpython-1d44c41b0cc183603b31ac943ef452456bef089f.tar.gz cpython-1d44c41b0cc183603b31ac943ef452456bef089f.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_fstring.py')
-rw-r--r-- | Lib/test/test_fstring.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index a6ff9cf..2a1a3cd 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -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): |