diff --git a/Scrapy-Redis-Zhihu/scrapy_redis/picklecompat.py b/Scrapy-Redis-Zhihu/scrapy_redis/picklecompat.py new file mode 100644 index 0000000..a8d85c0 --- /dev/null +++ b/Scrapy-Redis-Zhihu/scrapy_redis/picklecompat.py @@ -0,0 +1,14 @@ +"""A pickle wrapper module with protocol=-1 by default.""" + +try: + import cPickle as pickle # PY2 +except ImportError: + import pickle + + +def loads(s): + return pickle.loads(s) + + +def dumps(obj): + return pickle.dumps(obj, protocol=-1)