1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Make sure locals in safe_eval is a plain dict when running eval

Fixes #12206
This commit is contained in:
James Cammarata 2015-09-02 13:32:44 -04:00
parent 9ecfc30f9a
commit 5434ed973b

View file

@ -107,7 +107,7 @@ def safe_eval(expr, locals={}, include_exceptions=False):
parsed_tree = ast.parse(expr, mode='eval') parsed_tree = ast.parse(expr, mode='eval')
cnv.visit(parsed_tree) cnv.visit(parsed_tree)
compiled = compile(parsed_tree, expr, 'eval') compiled = compile(parsed_tree, expr, 'eval')
result = eval(compiled, {}, locals) result = eval(compiled, {}, dict(locals))
if include_exceptions: if include_exceptions:
return (result, None) return (result, None)