[CalendarServer-changes] [9939] CalendarServer/trunk/txdav/xml/base.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 15 14:22:35 PDT 2012
Revision: 9939
http://trac.calendarserver.org//changeset/9939
Author: wsanchez at apple.com
Date: 2012-10-15 14:22:35 -0700 (Mon, 15 Oct 2012)
Log Message:
-----------
WebDAVTextElement's __str__ should be sure to return bytes. Add toString() to return unicode.
Modified Paths:
--------------
CalendarServer/trunk/txdav/xml/base.py
Modified: CalendarServer/trunk/txdav/xml/base.py
===================================================================
--- CalendarServer/trunk/txdav/xml/base.py 2012-10-15 21:21:37 UTC (rev 9938)
+++ CalendarServer/trunk/txdav/xml/base.py 2012-10-15 21:22:35 UTC (rev 9939)
@@ -589,15 +589,26 @@
def fromString(clazz, string):
if string is None:
return clazz()
- elif isinstance(string, (str, unicode)):
+ elif isinstance(string, unicode):
return clazz(PCDATAElement(string))
+ elif isinstance(string, str):
+ return clazz(PCDATAElement(string.decode("utf-8")))
else:
return clazz(PCDATAElement(str(string)))
allowed_children = { PCDATAElement: (0, None) }
+ def toString(self):
+ """
+ @return: a unicode string containing the text in this element.
+ """
+ return u"".join([c.data for c in self.children])
+
def __str__(self):
- return "".join([c.data for c in self.children])
+ """
+ @return: a byte string containing the text in this element.
+ """
+ return self.toString().encode("utf-8")
def __repr__(self):
content = str(self)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121015/8ce6b7f8/attachment.html>
More information about the calendarserver-changes
mailing list