Commit 7fd66553 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

WIP: Revert "XMLExportImport: don't support bytes for now"

This reverts commit 3145b32f.

Otherwise, ERP5 site setup fails while importing erp5_core/ToolTemplateItem/portal_transforms.xml.

/SR/parts/erp5/product/ERP5/Document/BusinessTemplate.py(930)_importFile()
    928         # FIXME: Why not use the importXML function directly? Are there any BT5s
    929         # with actual .zexp files on the wild?
--> 930         obj = connection.importFile(file_obj, customImporters=customImporters)
    931       self._objects[obj_key] = obj
    932

ipdb> file_obj
<_io.BufferedReader name='/SR/parts/erp5/product/ERP5/bootstrap/erp5_core/ToolTemplateItem/portal_transforms.xml'>
...
> /SR/develop-eggs/zodbpickle-2.0.0+slapospatched001-py3.8-linux-x86_64.egg/zodbpickle/pickle_3.py(995)decode_string()
    993                 return value
    994         else:
--> 995             return value.decode(self.encoding, self.errors)
    996
    997     def load_string(self):

ipdb> p value
b'\x00\x00\x00\x00\x00\x00\x00\x80'
parent 40ed53ec
......@@ -710,17 +710,22 @@ def save_put(self, v, attrs):
def save_string(self, tag, data):
a = data[1]
v = b''.join(data[2:])
encoding = a.get('encoding', 'repr')
is_bytes = a.get('binary') == 'true' # XXX zope4py2: we don't use binary yet
encoding = a.get('encoding', 'repr') # JPS: repr is default encoding
if encoding is not '':
v = unconvert(encoding, v)
if self.binary:
l = len(v)
if l < 256:
op = SHORT_BINBYTES if is_bytes else SHORT_BINSTRING
if encoding == 'base64':
op = SHORT_BINBYTES
else:
op = SHORT_BINSTRING
v = op + six.int2byte(l) + v
else:
op = BINBYTES if is_bytes else BINSTRING
if encoding == 'base64':
op = BINBYTES
else:
op = BINSTRING
v = op + struct.pack('<i', l) + v
else:
v = STRING + repr(v) + '\n'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment