mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 04:41:26 -07:00
Add a import for 'builtins' module, used in CleansingNodeVisitor.
This was previously done by ./lib/ansible/utils/__init__.py, but this code is no longer here in v2 anymore. And since the module got renamed in python3 to builtins ( https://docs.python.org/3/library/builtins.html ), we have to use six.
This commit is contained in:
parent
b69f57d8a4
commit
0c74b356d2
1 changed files with 3 additions and 1 deletions
|
@ -20,6 +20,8 @@ __metaclass__ = type
|
||||||
import ast
|
import ast
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from six.moves import builtins
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.plugins import filter_loader
|
from ansible.plugins import filter_loader
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ def safe_eval(expr, locals={}, include_exceptions=False):
|
||||||
elif isinstance(node, ast.Call):
|
elif isinstance(node, ast.Call):
|
||||||
inside_call = True
|
inside_call = True
|
||||||
elif isinstance(node, ast.Name) and inside_call:
|
elif isinstance(node, ast.Name) and inside_call:
|
||||||
if hasattr(builtin, node.id) and node.id not in CALL_WHITELIST:
|
if hasattr(builtins, node.id) and node.id not in CALL_WHITELIST:
|
||||||
raise Exception("invalid function: %s" % node.id)
|
raise Exception("invalid function: %s" % node.id)
|
||||||
# iterate over all child nodes
|
# iterate over all child nodes
|
||||||
for child_node in ast.iter_child_nodes(node):
|
for child_node in ast.iter_child_nodes(node):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue