[Erp5-report] r46064 jm - /erp5/trunk/utils/xml_marshaller/src/xml_marshaller/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Feb 22 13:39:51 UTC 2019


Author: jm
Date: Fri Feb 22 13:39:50 2019
New Revision: 46064

URL: http://svn.erp5.org?rev=46064&view=rev
Log:
fixup! xml_marshaller: stop distinguish unicode and bytes and always return 'str'

We always returned unicode.

Modified:
    erp5/trunk/utils/xml_marshaller/src/xml_marshaller/xml_marshaller.py

Modified: erp5/trunk/utils/xml_marshaller/src/xml_marshaller/xml_marshaller.py
URL: http://svn.erp5.org/erp5/trunk/utils/xml_marshaller/src/xml_marshaller/xml_marshaller.py?rev=46064&r1=46063&r2=46064&view=diff
==============================================================================
--- erp5/trunk/utils/xml_marshaller/src/xml_marshaller/xml_marshaller.py [utf8] (original)
+++ erp5/trunk/utils/xml_marshaller/src/xml_marshaller/xml_marshaller.py [utf8] Fri Feb 22 13:39:50 2019
@@ -29,6 +29,11 @@ try:
   cmp
 except NameError:
   cmp = lambda x, y: (x > y) - (x < y)
+  def unicode2str(s):
+    return s
+else:
+  def unicode2str(s):
+    return s.encode('utf-8')
 
 @cmp_to_key
 def version_independent_cmp(a, b):
@@ -441,7 +446,7 @@ class Unmarshaller(ElementTreeContentHan
 
   def um_end_string(self, name):
     ds = self.data_stack
-    ds[-1] = unescape(''.join(ds[-1]))
+    ds[-1] = unicode2str(unescape(''.join(ds[-1])))
     self.accumulating_chars = 0
 
   def um_end_int(self, name):
@@ -583,10 +588,8 @@ class Unmarshaller(ElementTreeContentHan
             klass.__name__, err)), sys.exc_info()[2])
 
     # Now set the object's attributes from the marshalled dictionary
-    for k, v in kw.items():
-      if not isinstance(k, str):
-        k = k.decode()
-      setattr(value, k, v)
+    for x in kw.items():
+      setattr(value, *x)
     self.data_stack[-5:] = [value]
 
 # Helper class for instance unmarshalling



More information about the Erp5-report mailing list