Changeset - e84c2738fbd8
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 10 years ago 2015-08-06 11:42:57
thomas.de.schampheleire@gmail.com
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.
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_config.py
Show inline comments
 
@@ -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:
0 comments (0 inline, 0 general)