mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
Python 3: there's no 'unicode'
This commit is contained in:
parent
6d4618f46f
commit
56f2a25bff
1 changed files with 5 additions and 5 deletions
|
@ -22,7 +22,7 @@ __metaclass__ = type
|
||||||
import ast
|
import ast
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from six import string_types
|
from six import string_types, text_type, binary_type
|
||||||
from jinja2 import Environment
|
from jinja2 import Environment
|
||||||
from jinja2.loaders import FileSystemLoader
|
from jinja2.loaders import FileSystemLoader
|
||||||
from jinja2.exceptions import TemplateSyntaxError, UndefinedError
|
from jinja2.exceptions import TemplateSyntaxError, UndefinedError
|
||||||
|
@ -217,10 +217,10 @@ class Templar:
|
||||||
# Don't template unsafe variables, instead drop them back down to
|
# Don't template unsafe variables, instead drop them back down to
|
||||||
# their constituent type.
|
# their constituent type.
|
||||||
if hasattr(variable, '__UNSAFE__'):
|
if hasattr(variable, '__UNSAFE__'):
|
||||||
if isinstance(variable, unicode):
|
if isinstance(variable, text_type):
|
||||||
return unicode(variable)
|
return text_type(variable)
|
||||||
elif isinstance(variable, str):
|
elif isinstance(variable, binary_type):
|
||||||
return str(variable)
|
return bytes(variable)
|
||||||
else:
|
else:
|
||||||
return variable
|
return variable
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue