##// 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 foo = "bar"
44 foo = "bar"
45 print str(s)
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 """ # ' -> close an open quote for stupid emacs
48 """ # ' -> close an open quote for stupid emacs
49
49
50 #*****************************************************************************
50 #*****************************************************************************
@@ -104,7 +104,7 b' class Itpl:'
104 evaluation and substitution happens in the namespace of the
104 evaluation and substitution happens in the namespace of the
105 caller when str(instance) is called."""
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 """The single mandatory argument to this constructor is a format
108 """The single mandatory argument to this constructor is a format
109 string.
109 string.
110
110
@@ -198,7 +198,13 b' class Itpl:'
198 result = []
198 result = []
199 app = result.append
199 app = result.append
200 for live, chunk in self.chunks:
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 else: app(chunk)
208 else: app(chunk)
203 out = ''.join(result)
209 out = ''.join(result)
204 try:
210 try:
General Comments 0
You need to be logged in to leave comments. Login now