added tests for common.calculate_math_string

This commit is contained in:
Michael Pöhn 2018-05-22 13:24:37 +02:00
parent 24b20d7668
commit 6b1f242d25
2 changed files with 15 additions and 0 deletions

View file

@ -3224,6 +3224,8 @@ def calculate_math_string(expr):
raise SyntaxError(node)
try:
if '#' in expr:
raise SyntaxError('no comments allowed')
return execute_ast(ast.parse(expr, mode='eval').body)
except SyntaxError as e:
raise SyntaxError("could not parse expression '{expr}', "