Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Coerce string when calling compile_template_str #49943
What does this PR do?
This fixes a bug in the file_tree pillar which causes it to fail to render templates in python 3. The caller for the template rendering function passes bytes instead of string.
What issues does this PR fix or reference?
No. New functionality not added
Commits signed with GPG?
I have also marked this to be backported, for future reference, PRs that fix bugs should be opened against the oldest feature release that the bug is present in, so in this case that would be the 2018.3 branch. (2018.3.3 is a release branch and not the main feature branch)
terminalmage left a comment
However, because we are encoding, we want the contents to be unicode first, otherwise Python 2 will break when non-ascii characters are present in the string we pass:
>>> 'groß'.encode('utf-8') Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
Therefore, please change from