diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-11-20 14:34:40 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-11-20 15:50:28 -0500 |
commit | d885b4333f18591ddccdf2bb28fdae2f772589af (patch) | |
tree | 5e3e388a8f97ba32b8e2a910670372863188d567 | |
parent | e4cbdc83e4779e83c83944b29beff50c5a2efb1a (diff) | |
download | dogpile-cache-d885b4333f18591ddccdf2bb28fdae2f772589af.tar.gz |
apply staticmethod() to pickle.dumps/loads as class variables
Fixed regression where the serialization and deserialization functions
could be inadvertently turned into instance methods with an unexpected
argument signature, namely when pickle.dumps and pickle.loads are the pure
Python version as is the case in pypy.
Fixes: #195
Change-Id: Ie8b332510a1d5d0a6c34ed4338f2a71e327676a8
-rw-r--r-- | docs/build/unreleased/195.rst | 9 | ||||
-rw-r--r-- | dogpile/cache/api.py | 12 |
2 files changed, 17 insertions, 4 deletions
diff --git a/docs/build/unreleased/195.rst b/docs/build/unreleased/195.rst new file mode 100644 index 0000000..e7ba8f4 --- /dev/null +++ b/docs/build/unreleased/195.rst @@ -0,0 +1,9 @@ +.. change:: + :tags: bug, region + :tickets: 195 + + Fixed regression where the serialization and deserialization functions + could be inadvertently turned into instance methods with an unexpected + argument signature, namely when pickle.dumps and pickle.loads are the pure + Python version as is the case in pypy. + diff --git a/dogpile/cache/api.py b/dogpile/cache/api.py index d89ac56..3d6bfa4 100644 --- a/dogpile/cache/api.py +++ b/dogpile/cache/api.py @@ -141,7 +141,7 @@ class CacheBackend: """ - serializer: Optional[Serializer] = None + serializer: Union[None, Serializer, staticmethod] = None """Serializer function that will be used by default if not overridden by the region. @@ -149,7 +149,7 @@ class CacheBackend: """ - deserializer: Optional[Deserializer] = None + deserializer: Union[None, Deserializer, staticmethod] = None """deserializer function that will be used by default if not overridden by the region. @@ -435,8 +435,12 @@ class CacheBackend: class DefaultSerialization: - serializer: Optional[Serializer] = pickle.dumps - deserializer: Optional[Deserializer] = pickle.loads + serializer: Union[None, Serializer, staticmethod] = staticmethod( + pickle.dumps + ) + deserializer: Union[None, Deserializer, staticmethod] = staticmethod( + pickle.loads + ) class BytesBackend(DefaultSerialization, CacheBackend): |