Commit 685f7a7e authored by Stefan Behnel's avatar Stefan Behnel

Make the pickle test actually test that auto-pickling uses the right checksum...

Make the pickle test actually test that auto-pickling uses the right checksum (and not a user implemented reduce method that uses no checksums at all).
parent d3b277ea
...@@ -62,9 +62,6 @@ cdef class B: ...@@ -62,9 +62,6 @@ cdef class B:
def __reduce__(self): def __reduce__(self):
return makeObj, (type(self), {'x': self.x, 'y': self.y}) return makeObj, (type(self), {'x': self.x, 'y': self.y})
def __eq__(self, other):
return isinstance(other, B) and (<B>other).x == self.x and (<B>other).y == self.y
def makeObj(obj_type, kwds): def makeObj(obj_type, kwds):
return obj_type(**kwds) return obj_type(**kwds)
...@@ -119,6 +116,14 @@ cdef class DefaultReduceSubclass(DefaultReduce): ...@@ -119,6 +116,14 @@ cdef class DefaultReduceSubclass(DefaultReduce):
def __repr__(self): def __repr__(self):
return "DefaultReduceSubclass(i=%s, s=%r, x=%s)" % (self.i, self.s, self.x) return "DefaultReduceSubclass(i=%s, s=%r, x=%s)" % (self.i, self.s, self.x)
def __eq__(self, other):
return (
isinstance(other, DefaultReduceSubclass) and
(<DefaultReduceSubclass>other).i == self.i and
(<DefaultReduceSubclass>other).s == self.s and
(<DefaultReduceSubclass>other).x == self.x
)
cdef class result(DefaultReduceSubclass): cdef class result(DefaultReduceSubclass):
""" """
...@@ -311,9 +316,10 @@ if sys.version_info[:2] >= (3, 5): ...@@ -311,9 +316,10 @@ if sys.version_info[:2] >= (3, 5):
# Pickled with Cython 0.29.28 (using MD5 for the checksum). # Pickled with Cython 0.29.28 (using MD5 for the checksum).
OLD_MD5_PICKLE = b'''\ OLD_MD5_PICKLE = b'''\
\x80\x04\x95:\x00\x00\x00\x00\x00\x00\x00\x8c\rreduce_pickle\ \x80\x04\x95t\x00\x00\x00\x00\x00\x00\x00\x8c\rreduce_pickle\
\x94\x8c\x07makeObj\x94\x93\x94h\x00\x8c\x01B\x94\x93\x94}\ \x94\x8c$__pyx_unpickle_DefaultReduceSubclass\x94\x93\x94h\x00\x8c\x15\
\x94(\x8c\x01x\x94K%\x8c\x01y\x94M\x85\x01u\x86\x94R\x94.\ DefaultReduceSubclass\x94\x93\x94J\x8eYi\x08N\x87\x94R\x94K\x0b\x8c\x03\
abc\x94G?\xf8\x00\x00\x00\x00\x00\x00\x87\x94b.\
''' '''
try: try:
...@@ -325,6 +331,6 @@ else: ...@@ -325,6 +331,6 @@ else:
""" """
>>> import pickle >>> import pickle
>>> b = pickle.loads(OLD_MD5_PICKLE) >>> b = pickle.loads(OLD_MD5_PICKLE)
>>> b == B(x=37, y=389) or b >>> b == DefaultReduceSubclass(i=11, s='abc', x=1.5) or b
True True
""" """
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