Commit ca42cbc4 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

XMLExportImport: don't support bytes for now

XMLExportImport encode strings in base64 when they can not safely be
represented in XML (including for exemple "\n"), so we can not use
this information to decide if this a BINBYTES or a BINSTRING pickle
opcode.

For now, it's still unclear how bytes and str should be handled, so
while using python2 it's better to keep using str everywhere and not
introduce zodbpickle.binary that looks like str on python2 but will
become bytes on python3 and have consistent data everywhere (ie.
everything str)

BINBYTES is not fully removed from the patch, because we'll want to
use it later, but it is in "if" that is always false.
parent 9e50731e
......@@ -709,22 +709,17 @@ 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') # JPS: repr is default encoding
encoding = a.get('encoding', 'repr')
is_bytes = a.get('binary') == 'true' # XXX zope4py2: we don't use binary yet
if encoding is not '':
v = unconvert(encoding, v)
if self.binary:
l = len(v)
if l < 256:
if encoding == 'base64':
op = SHORT_BINBYTES
else:
op = SHORT_BINSTRING
op = SHORT_BINBYTES if is_bytes else SHORT_BINSTRING
v = op + six.int2byte(l) + v
else:
if encoding == 'base64':
op = BINBYTES
else:
op = BINSTRING
op = BINBYTES if is_bytes else 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