Fix support for Python < 3.4.

This commit is contained in:
Valentin Lorentz 2017-02-25 13:24:03 +01:00
parent dab026169f
commit 355ff7ffdf

View File

@ -186,7 +186,10 @@ def safeEval(s, namespace=None):
return all([checkNode(x) for x in node.values]) and \ return all([checkNode(x) for x in node.values]) and \
all([checkNode(x) for x in node.values]) all([checkNode(x) for x in node.values])
elif node.__class__ is ast.Name: elif node.__class__ is ast.Name:
if node.id in namespace: if namespace is None and node.id in ('True', 'False', 'None'):
# For Python < 3.4, which does not have NameConstant.
return True
elif namespace is not None and node.id in namespace:
return True return True
else: else:
return False return False