From 56f2a25bff43eaf5ba9339a97303e25841fa8b79 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 24 Sep 2015 12:52:51 +0300 Subject: [PATCH] Python 3: there's no 'unicode' --- lib/ansible/template/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index dc74d2cb566..20287e078c6 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -22,7 +22,7 @@ __metaclass__ = type import ast import re -from six import string_types +from six import string_types, text_type, binary_type from jinja2 import Environment from jinja2.loaders import FileSystemLoader from jinja2.exceptions import TemplateSyntaxError, UndefinedError @@ -217,10 +217,10 @@ class Templar: # Don't template unsafe variables, instead drop them back down to # their constituent type. if hasattr(variable, '__UNSAFE__'): - if isinstance(variable, unicode): - return unicode(variable) - elif isinstance(variable, str): - return str(variable) + if isinstance(variable, text_type): + return text_type(variable) + elif isinstance(variable, binary_type): + return bytes(variable) else: return variable