From c824e50b3f2e752e324a3ec56224d8c464950287 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Tue, 15 Mar 2016 11:25:16 +0100 Subject: [PATCH] [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 --- openerp/cli/scaffold.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/cli/scaffold.py b/openerp/cli/scaffold.py index 8b9a4bede14..442abcdfba0 100644 --- a/openerp/cli/scaffold.py +++ b/openerp/cli/scaffold.py @@ -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')