From e842d6408e78e17f7ae96b075e3039dd3315fcf1 Mon Sep 17 00:00:00 2001 From: Ivan Moiseev Date: Sat, 22 Oct 2022 21:06:38 +0400 Subject: [PATCH] feat: make PickleCoder compatible with backends --- fastapi_cache/coder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fastapi_cache/coder.py b/fastapi_cache/coder.py index 5d7e4a5..3bc2aa0 100644 --- a/fastapi_cache/coder.py +++ b/fastapi_cache/coder.py @@ -39,7 +39,7 @@ def object_hook(obj: Any) -> Any: class Coder: @classmethod - def encode(cls, value: Any) -> Union[str, bytes]: + def encode(cls, value: Any) -> str: raise NotImplementedError @classmethod @@ -59,9 +59,9 @@ class JsonCoder(Coder): class PickleCoder(Coder): @classmethod - def encode(cls, value: Any) -> Union[str, bytes]: - return pickle.dumps(value) + def encode(cls, value: Any) -> str: + return str(pickle.dumps(value)) @classmethod def decode(cls, value: Any) -> Any: - return pickle.loads(value) # nosec:B403,B301 + return pickle.loads(bytes(value)) # nosec:B403,B301