1
0
forked from VimPlug/jedi

None/False/True are atom non-terminals in the syntax tree, fixes #1103

This commit is contained in:
Dave Halter
2018-05-01 23:40:52 +02:00
parent 8d48e7453a
commit a95274d66f
2 changed files with 12 additions and 9 deletions

View File

@@ -68,16 +68,8 @@ def eval_node(context, element):
debug.dbg('eval_node %s@%s', element, element.start_pos)
evaluator = context.evaluator
typ = element.type
if typ in ('name', 'number', 'string', 'atom', 'strings'):
if typ in ('name', 'number', 'string', 'atom', 'strings', 'keyword'):
return eval_atom(context, element)
elif typ == 'keyword':
# For False/True/None
if element.value in ('False', 'True', 'None'):
return ContextSet(compiled.builtin_from_name(evaluator, element.value))
if element.value == 'print':
# print e.g. could be evaluated like this in Python 2.7
return NO_CONTEXTS
assert False, 'Cannot evaluate the keyword %s' % element
elif typ == 'lambdef':
return ContextSet(FunctionContext(evaluator, context, element))
elif typ == 'expr_stmt':
@@ -209,6 +201,14 @@ def eval_atom(context, atom):
position=stmt.start_pos,
search_global=True
)
elif atom.type == 'keyword':
# For False/True/None
if atom.value in ('False', 'True', 'None'):
return ContextSet(compiled.builtin_from_name(context.evaluator, atom.value))
if atom.value == 'print':
# print e.g. could be evaluated like this in Python 2.7
return NO_CONTEXTS
assert False, 'Cannot evaluate the keyword %s' % atom
elif isinstance(atom, tree.Literal):
string = context.evaluator.compiled_subprocess.safe_literal_eval(atom.value)