# HG changeset patch # User Thomas De Schampheleire # Date 2015-08-06 11:42:57 # Node ID e84c2738fbd84569492c56e5a9361ee94af5d420 # Parent 2098b682f28f1f4d91b88d37e1984fff2af8bca9 kallithea_config: properly handle Unicode characters in .ini template template.ini.mako declares itself as UTF-8, but actually putting unicode in the file made kallithea_config.py fail with UnicodeEncodeError. Fix by making sure the template is read as UTF-8. diff --git a/kallithea/bin/kallithea_config.py b/kallithea/bin/kallithea_config.py --- a/kallithea/bin/kallithea_config.py +++ b/kallithea/bin/kallithea_config.py @@ -132,13 +132,13 @@ def _run(argv): tmpl_file = args.template with open(tmpl_file, 'rb') as f: - tmpl_data = f.read() + tmpl_data = f.read().decode('utf-8') if args.raw: tmpl = tmpl_data else: tmpl = Template(tmpl_data).render(**tmpl_stored_args) with open(args.filename, 'wb') as f: - f.write(tmpl) + f.write(tmpl.encode('utf-8')) print 'Wrote new config file in %s' % (os.path.abspath(args.filename)) except Exception: