Fix f-string evaluation, fixes #1248

This commit is contained in:
Dave Halter
2018-12-23 15:32:22 +01:00
parent 86fbf3fef6
commit 5e7ff808d4
2 changed files with 7 additions and 1 deletions

View File

@@ -69,7 +69,7 @@ def eval_node(context, element):
debug.dbg('eval_node %s@%s in %s', element, element.start_pos, context)
evaluator = context.evaluator
typ = element.type
if typ in ('name', 'number', 'string', 'atom', 'strings', 'keyword'):
if typ in ('name', 'number', 'string', 'atom', 'strings', 'keyword', 'fstring'):
return eval_atom(context, element)
elif typ == 'lambdef':
return ContextSet([FunctionContext.from_context(context, element)])
@@ -221,6 +221,8 @@ def eval_atom(context, atom):
right = eval_atom(context, string)
context_set = _eval_comparison(context.evaluator, context, context_set, u'+', right)
return context_set
elif atom.type == 'fstring':
return compiled.get_string_context_set(context.evaluator)
else:
c = atom.children
# Parentheses without commas are not tuples.

View File

@@ -32,3 +32,7 @@ f'xyz'.uppe
#? 3 []
f'f'
# Github #1248
#? int()
{"foo": 1}[f"foo"]