From 6d4b7f27ba8a88abb9a4e784f5fdb12de3be7ff7 Mon Sep 17 00:00:00 2001 From: Eric Vin <8935814+Eric-Vin@users.noreply.github.com> Date: Wed, 1 Nov 2023 04:46:23 -0700 Subject: [PATCH] Added fstring test case and potential fix. (#96) --- data/python.gram | 2 +- tests/python_parser/data/fstrings.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/data/python.gram b/data/python.gram index bf20268..c1f478b 100644 --- a/data/python.gram +++ b/data/python.gram @@ -1696,7 +1696,7 @@ fstring_full_format_spec: ) } fstring_format_spec: - | t=FSTRING_MIDDLE { ast.Constant(value=t.string.encode(), LOCATIONS) } + | t=FSTRING_MIDDLE { ast.Constant(value=t.string, LOCATIONS) } | fstring_replacement_field fstring: | a=FSTRING_START b=fstring_mid* c=FSTRING_END { diff --git a/tests/python_parser/data/fstrings.py b/tests/python_parser/data/fstrings.py index af5c2f7..c2773e7 100644 --- a/tests/python_parser/data/fstrings.py +++ b/tests/python_parser/data/fstrings.py @@ -64,4 +64,7 @@ -f'{expr:}' \ No newline at end of file +f'{expr:}' + +foo = 3.14159 +verbosePrint(f'Foo {foo:.3} bar.')