summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2022-03-14 13:33:55 +0100
committerStefan Behnel <stefan_ml@behnel.de>2022-03-14 13:53:31 +0100
commit5fc919e3f8bda8d1e07e66701b61e16511b0ec01 (patch)
tree876cd89b5a1a30c1072fc235a648207401c40831 /tests
parentafc00fc3ba5d43c67151c0039847a526e7b627a5 (diff)
downloadcython-5fc919e3f8bda8d1e07e66701b61e16511b0ec01.tar.gz
For the auto-pickle checksum, allow SHA-1 and SHA-256 which are used by Cython 3.x pickles now. Otherwise stick to MD5 since that was used before.
Closes https://github.com/cython/cython/issues/4680
Diffstat (limited to 'tests')
-rw-r--r--tests/run/reduce_pickle.pyx24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/run/reduce_pickle.pyx b/tests/run/reduce_pickle.pyx
index 537f720a1..f2a9881a7 100644
--- a/tests/run/reduce_pickle.pyx
+++ b/tests/run/reduce_pickle.pyx
@@ -62,6 +62,9 @@ cdef class B:
def __reduce__(self):
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):
return obj_type(**kwds)
@@ -304,3 +307,24 @@ if sys.version_info[:2] >= (3, 5):
"""
def my_method(self, x):
return x
+
+
+# Pickled with Cython 0.29.28 (using MD5 for the checksum).
+OLD_MD5_PICKLE = b'''\
+\x80\x04\x95:\x00\x00\x00\x00\x00\x00\x00\x8c\rreduce_pickle\
+\x94\x8c\x07makeObj\x94\x93\x94h\x00\x8c\x01B\x94\x93\x94}\
+\x94(\x8c\x01x\x94K%\x8c\x01y\x94M\x85\x01u\x86\x94R\x94.\
+'''
+
+try:
+ from hashlib import md5
+except ImportError:
+ pass
+else:
+ def unpickle_old_0_29_28():
+ """
+ >>> import pickle
+ >>> b = pickle.loads(OLD_MD5_PICKLE)
+ >>> b == B(x=37, y=389) or b
+ True
+ """