Commit 2f429e61 authored by Marius Gedminas's avatar Marius Gedminas

Normalize fstail output on Python 3

The only remaining test failures are due to changed pickle sizes.  I've
discovered two reasons for that so far:

  1) Python 3 pickles 'native strings' as BINUNICODE, Python 2 pickles
     'native strings' as SHORT_BINSTRING, which is 3 bytes shorter.

  2) Python 3 and also the 'pickle' module Python 2 pickles tuples like
     (UserDefinedClass, ) with an extra BINPUT opcode at the end,
     compared to 'cPickle' in Python 2 when given the same tuple:

        Python 2.7.3 (default, Sep 26 2012, 21:51:14)
        [GCC 4.7.2] on linux2
        Type "help", "copyright", "credits" or "license" for more information.
        >>> import pickle, cPickle
        >>> class MyClass(object): pass
        ...
        >>> len(pickle.dumps((MyClass, None), 1))
        26
        >>> len(cPickle.dumps((MyClass, None), 1))
        24

The plan is to switch to zodbpickle instead of the builtin Python 3
pickle, then use encoding=bytes from http://bugs.python.org/issue6784
and fix the class-in-tuple encoding to match Python 2's cPickle.
parent a0978648
......@@ -35,7 +35,7 @@ def main(path, ntxn):
l = len(str(th.get_timestamp())) + 1
th.read_meta()
print("%s: hash=%s" % (th.get_timestamp(),
binascii.hexlify(hash)))
binascii.hexlify(hash).decode()))
print(("user=%r description=%r length=%d offset=%d"
% (th.user, th.descr, th.length, th.get_data_offset())))
print()
......
......@@ -22,7 +22,11 @@ checker = zope.testing.renormalizing.RENormalizing([
'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+'),
'2007-11-10 15:18:48.543001'),
(re.compile('hash=[0-9a-f]{40}'),
'hash=b16422d09fabdb45d4e4325e4b42d7d6f021d3c3')])
'hash=b16422d09fabdb45d4e4325e4b42d7d6f021d3c3'),
# Python 3 bytes add a "b".
(re.compile("b('.*?')"), r"\1"),
(re.compile('b(".*?")'), r"\1"),
])
def test_suite():
return unittest.TestSuite((
......
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