summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Charriere <nicholas@pinterest.com>2017-06-02 11:56:43 -0700
committerNicholas Charriere <nicholas@pinterest.com>2017-06-02 11:56:43 -0700
commit367640d22e935b20027da80a3616b1acaa598de5 (patch)
tree99b68e27aa07f885aa61d843916dab1f7617ce4b
parent2fa8395d7655531c0635e58bdd50c7dc8f7cffd6 (diff)
downloadpymemcache-revert.tar.gz
Reverse backwards compatible changerevert
-rw-r--r--pymemcache/serde.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pymemcache/serde.py b/pymemcache/serde.py
index 6291d61..98bde52 100644
--- a/pymemcache/serde.py
+++ b/pymemcache/serde.py
@@ -30,6 +30,14 @@ FLAG_LONG = 1 << 2
FLAG_COMPRESSED = 1 << 3 # unused, to main compatability with python-memcached
FLAG_TEXT = 1 << 4
+# Pickle protocol version (-1 for highest available to runtime)
+# Warning with `0`: If somewhere in your value lies a slotted object,
+# ie defines `__slots__`, even if you do not include it in your pickleable
+# state via `__getstate__`, python will complain with something like:
+# TypeError: a class that defines __slots__ without defining __getstate__
+# cannot be pickled
+PICKLE_VERSION = -1
+
def python_memcache_serializer(key, value):
flags = 0
@@ -55,7 +63,7 @@ def python_memcache_serializer(key, value):
else:
flags |= FLAG_PICKLE
output = BytesIO()
- pickler = pickle.Pickler(output, 0)
+ pickler = pickle.Pickler(output, PICKLE_VERSION)
pickler.dump(value)
value = output.getvalue()