|
From: <sub...@co...> - 2008-05-15 15:42:57
|
Author: ianb
Date: 2008-05-15 09:41:23 -0600 (Thu, 15 May 2008)
New Revision: 3430
Modified:
FormEncode/trunk/formencode/rewritingparser.py
Log:
coerce objects to unicode when they want to be so coerced
Modified: FormEncode/trunk/formencode/rewritingparser.py
===================================================================
--- FormEncode/trunk/formencode/rewritingparser.py 2008-05-14 19:31:18 UTC (rev 3429)
+++ FormEncode/trunk/formencode/rewritingparser.py 2008-05-15 15:41:23 UTC (rev 3430)
@@ -11,8 +11,11 @@
elif isinstance(v, basestring):
return cgi.escape(v, 1)
else:
- # @@: Should this be unicode(v) or str(v)?
- return cgi.escape(str(v), 1)
+ if hasattr(v, '__unicode__'):
+ v = unicode(v)
+ else:
+ v = str(v)
+ return cgi.escape(v, 1)
class RewritingParser(HTMLParser.HTMLParser):
|