diff --git a/lib/ansible/template/safe_eval.py b/lib/ansible/template/safe_eval.py index d82373a6fb9..845216b621d 100644 --- a/lib/ansible/template/safe_eval.py +++ b/lib/ansible/template/safe_eval.py @@ -26,6 +26,12 @@ from ansible.compat.six.moves import builtins from ansible import constants as C from ansible.plugins import filter_loader, test_loader +try: + from __main__ import display +except ImportError: + from ansible.utils.display import Display + display = Display() + def safe_eval(expr, locals={}, include_exceptions=False): ''' This is intended for allowing things like: @@ -131,13 +137,14 @@ def safe_eval(expr, locals={}, include_exceptions=False): else: return result except SyntaxError as e: + display.warning('SyntaxError in safe_eval() on expr: %s (%s)' % (expr, e)) # special handling for syntax errors, we just return # the expression string back as-is if include_exceptions: return (expr, None) return expr except Exception as e: + display.warning('Exception in safe_eval() on expr: %s (%s)' % (expr, e)) if include_exceptions: return (expr, e) return expr -