Merge pull request #46432 from twangboy/win_locales_utf8

Default to UTF-8 for templated files
This commit is contained in:
Nicole Thomas 2018-03-26 15:02:13 -04:00 committed by GitHub
commit ac2a6616a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -410,7 +410,14 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
decoded_context[key] = value
continue
decoded_context[key] = salt.utils.locales.sdecode(value)
try:
decoded_context[key] = salt.utils.to_unicode(value, encoding=SLS_ENCODING)
except UnicodeDecodeError as ex:
log.debug(
"Failed to decode using default encoding (%s), trying system encoding",
SLS_ENCODING,
)
decoded_context[key] = salt.utils.locales.sdecode(value)
try:
template = jinja_env.from_string(tmplstr)