[Erp5-report] r46065 jm - in /erp5/trunk/utils/xml_marshaller: ./ src/xml_marshaller/ src/x...
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Feb 22 14:54:39 UTC 2019
Author: jm
Date: Fri Feb 22 14:54:38 2019
New Revision: 46065
URL: http://svn.erp5.org?rev=46065&view=rev
Log:
xml_marshaller: fix dump of bytes with Python 2 and update tests
Modified:
erp5/trunk/utils/xml_marshaller/README.txt
erp5/trunk/utils/xml_marshaller/src/xml_marshaller/tests/test_xml_marshaller.py
erp5/trunk/utils/xml_marshaller/src/xml_marshaller/xml_marshaller.py
Modified: erp5/trunk/utils/xml_marshaller/README.txt
URL: http://svn.erp5.org/erp5/trunk/utils/xml_marshaller/README.txt?rev=46065&r1=46064&r2=46065&view=diff
==============================================================================
--- erp5/trunk/utils/xml_marshaller/README.txt [utf8] (original)
+++ erp5/trunk/utils/xml_marshaller/README.txt [utf8] Fri Feb 22 14:54:38 2019
@@ -29,10 +29,10 @@ For simple serialisation and unserialisa
>>> from xml_marshaller import xml_marshaller
- >>> xml_marshaller.dumps(['item1', {'key1': 1, 'key2': u'unicode string'}])
- '<marshal><list id="i2"><string>item1</string><dictionary id="i3"><string>key1</string><int>1</int><string>key2</string><unicode>unicode string</unicode></dictionary></list></marshal>'
- >>> xml_marshaller.loads(xml_marshaller.dumps(['item1', {'key1': 1, 'key2': u'unicode string'}]))
- ['item1', {'key2': u'unicode string', 'key1': 1}]
+ >>> xml_marshaller.dumps(['item1', {'key1': 1, 'key2': 'string'}])
+ '<marshal><list id="i2"><string>item1</string><dictionary id="i3"><string>key1</string><int>1</int><string>key2</string><string>string</string></dictionary></list></marshal>'
+ >>> xml_marshaller.loads(xml_marshaller.dumps(['item1', {'key1': 1, 'key2': 'string'}]))
+ ['item1', {'key2': 'string', 'key1': 1}]
Can works with file like objects::
Modified: erp5/trunk/utils/xml_marshaller/src/xml_marshaller/tests/test_xml_marshaller.py
URL: http://svn.erp5.org/erp5/trunk/utils/xml_marshaller/src/xml_marshaller/tests/test_xml_marshaller.py?rev=46065&r1=46064&r2=46065&view=diff
==============================================================================
--- erp5/trunk/utils/xml_marshaller/src/xml_marshaller/tests/test_xml_marshaller.py [utf8] (original)
+++ erp5/trunk/utils/xml_marshaller/src/xml_marshaller/tests/test_xml_marshaller.py [utf8] Fri Feb 22 14:54:38 2019
@@ -60,7 +60,7 @@ class TestXMLMarhsaller(unittest.TestCas
['alpha', 'beta', 'gamma', [None, 1, 1<<123, 19.72,
1+5j, "& a <fake tag>"]],
{'key': 'value', 1: 2},
- u'éàù^ç',
+ 'éàù^ç',
{'a', 1},
True,
False,
@@ -83,7 +83,7 @@ class TestXMLMarhsaller(unittest.TestCas
['alpha', 'beta', 'gamma', [None, 1, 1<<123, 19.72,
1+5j, "& a <fake tag>"]],
{'key': 'value', 1: 2},
- u'éàù^ç',
+ 'éàù^ç',
{'a', 1},
True,
False,
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=46065&r1=46064&r2=46065&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 14:54:38 2019
@@ -161,7 +161,9 @@ class Marshaller(object):
def m_bytes(self, value, kw):
return self.m_string(value.decode('utf-8'), kw)
- m_unicode = m_str
+ if str is bytes:
+ m_unicode = m_str
+ m_str = m_bytes
def m_int(self, value, kw):
return (self.tag_int if -1e24 < value < 1e24 else
More information about the Erp5-report
mailing list