I've running Python 2.6.6.
cat tbuild.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from mako.template import Template
_template="""
% for v in my_list:
${'abc'.encode('utf-8')}
${'風連町?'.encode('utf-8')}
% endfor
"""
print Template(_template).render_unicode(my_list = [1, 2],
input_encoding='utf-8',
output_encoding='utf-8',
encoding_errors='replace'
)
./tbuild.py gives.
File "./tbuild.py",
line 15, in <module> print Template(_template).render_unicode(my_list = [1, 2],
File "/usr/lib/python2.6/site-packages/mako/template.py",
line 91, in __init__ (code, module) = _compile_text(self, text, filename)
File "/usr/lib/python2.6/site-packages/mako/template.py",
line 357, in _compile_text node = lexer.parse()
File "/usr/lib/python2.6/site-packages/mako/lexer.py",
line 192, in parse self.filename,)
File "/usr/lib/python2.6/site-packages/mako/lexer.py",
line 184, in decode_raw_stream 0, 0, filename)
mako.exceptions.CompileException: Unicode decode operation of
encoding 'ascii' failed at line: 0 char: 0
If I remove the line with Japanese it works fine. There clearly is something fundamental that I'm miss understanding.
Thanks for your help, eo