[CalendarServer-changes] [9943] CalendarServer/trunk/txdav/xml/base.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 15 17:34:32 PDT 2012


Revision: 9943
          http://trac.calendarserver.org//changeset/9943
Author:   wsanchez at apple.com
Date:     2012-10-15 17:34:32 -0700 (Mon, 15 Oct 2012)
Log Message:
-----------
PCDATAElement converts to utf-8 internally.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/xml/base.py

Modified: CalendarServer/trunk/txdav/xml/base.py
===================================================================
--- CalendarServer/trunk/txdav/xml/base.py	2012-10-15 23:20:25 UTC (rev 9942)
+++ CalendarServer/trunk/txdav/xml/base.py	2012-10-16 00:34:32 UTC (rev 9943)
@@ -589,10 +589,8 @@
     def fromString(clazz, string):
         if string is None:
             return clazz()
-        elif isinstance(string, unicode):
+        elif isinstance(string, (unicode, str)):
             return clazz(PCDATAElement(string))
-        elif isinstance(string, str):
-            return clazz(PCDATAElement(string.decode("utf-8")))
         else:
             return clazz(PCDATAElement(str(string)))
 
@@ -602,13 +600,13 @@
         """
         @return: a unicode string containing the text in this element.
         """
-        return u"".join([c.data for c in self.children])
+        return self.__str__().decode("utf-8")
 
     def __str__(self):
         """
         @return: a byte string containing the text in this element.
         """
-        return self.toString().encode("utf-8")
+        return b"".join([c.data for c in self.children])
 
     def __repr__(self):
         content = str(self)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121015/9c8612c2/attachment-0001.html>


More information about the calendarserver-changes mailing list