From 7bc754674cf263ad685e4998dfab00375142d76a Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Tue, 19 Dec 2017 17:34:46 -0500 Subject: [PATCH] [template/vars] Use to_native(exception) as a fallback for Python 3 which doesn't have a .message attribute (#34044) --- lib/ansible/template/vars.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/template/vars.py b/lib/ansible/template/vars.py index 86837a9a799..7ce650ff7d6 100644 --- a/lib/ansible/template/vars.py +++ b/lib/ansible/template/vars.py @@ -105,7 +105,10 @@ class AnsibleJ2Vars(Mapping): try: value = self._templar.template(variable) except Exception as e: - raise type(e)(to_native(variable) + ': ' + e.message) + try: + raise type(e)(to_native(variable) + ': ' + e.message) + except AttributeError: + raise type(e)(to_native(variable) + ': ' + to_native(e)) return value def add_locals(self, locals):