Mercurial > kallithea
changeset 5373:e84c2738fbd8
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.
author | Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> |
---|---|
date | Thu, 06 Aug 2015 11:42:57 +0200 |
parents | 2098b682f28f |
children | d69aa464f373 |
files | kallithea/bin/kallithea_config.py |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/bin/kallithea_config.py Sat Aug 08 13:55:15 2015 +0200 +++ b/kallithea/bin/kallithea_config.py Thu Aug 06 11:42:57 2015 +0200 @@ -132,13 +132,13 @@ 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: