[FIX] scaffold: correctly decode utf8 templates
As its documentation notes[0], Jinja2 only processes unicode template data (or pure ASCII, which will implicitly decode to unicode). The scaffolding system would read raw scaffolding data in memory (both templates and passthrough non-templates), but fail to decode templates before handing them to Jinja, blowing rendering up if templates contained non-ascii. Fix #11331 by always decoding templates from UTF8 before handing them to jinja. This is backwards-compatible, ascii templates work as they used to, non-ascii UTF8 templates now work correctly, non-ascii non-UTF8 templates what are you doing? [0] http://jinja.pocoo.org/docs/dev/api/#unicode
This commit is contained in:
parent
d377ffd5bf
commit
c824e50b3f
|
@ -126,7 +126,7 @@ class template(object):
|
|||
if ext not in ('.py', '.xml', '.csv', '.js', '.rst', '.html', '.template'):
|
||||
f.write(content)
|
||||
else:
|
||||
env.from_string(content)\
|
||||
env.from_string(content.decode('utf-8'))\
|
||||
.stream(params or {})\
|
||||
.dump(f, encoding='utf-8')
|
||||
|
||||
|
|
Loading…
Reference in New Issue