##// END OF EJS Templates
Itpl now does not croak on unicode in 'live' template parts -> non-ascii prompts allowed. Closes #168
vivainio -
Show More
@@ -44,7 +44,7 b' each time the instance is evaluated with str(instance). For example:'
44 44 foo = "bar"
45 45 print str(s)
46 46
47 $Id: Itpl.py 958 2005-12-27 23:17:51Z fperez $
47 $Id: Itpl.py 2918 2007-12-31 14:34:47Z vivainio $
48 48 """ # ' -> close an open quote for stupid emacs
49 49
50 50 #*****************************************************************************
@@ -104,7 +104,7 b' class Itpl:'
104 104 evaluation and substitution happens in the namespace of the
105 105 caller when str(instance) is called."""
106 106
107 def __init__(self, format,codec='utf_8',encoding_errors='backslashreplace'):
107 def __init__(self, format,codec=sys.stdin.encoding,encoding_errors='backslashreplace'):
108 108 """The single mandatory argument to this constructor is a format
109 109 string.
110 110
@@ -198,7 +198,13 b' class Itpl:'
198 198 result = []
199 199 app = result.append
200 200 for live, chunk in self.chunks:
201 if live: app(str(eval(chunk,glob,loc)))
201 if live:
202 val = eval(chunk,glob,loc)
203 try:
204 app(str(val))
205 except UnicodeEncodeError:
206 app(unicode(val))
207
202 208 else: app(chunk)
203 209 out = ''.join(result)
204 210 try:
General Comments 0
You need to be logged in to leave comments. Login now