Closed
Description
the thing is that:
>>> from redis import StrictRedis
>>> r=StrictRedis(decode_responses=True)
>>> r.set('data1',{'aa':11})
>>> r.get('data1')
throw UnicodeDecodeError: 'utf-8' codec can't decode byte...
I know it can r.set('data1',json.dumps({'aa':11})) or use r.hmset('data1',{'aa':11}) to slove, but that is example to describe it. there is more complex scene like session pickle to redis or other meanwhile also want to use decode_responses=True.
but if i don't use decode_responses=True. i have to do manual decode() everytime.
So,what can i do if there is pickle data when use decode_responses=True.
My solve is change the connection.py about line 279:
if isinstance(response, bytes) and self.encoding:
import pickle
from pickle import UnpicklingError
try:
response = pickle.loads(response)
except UnpicklingError as e:
response = response.decode(self.encoding)
return response
so,can this merge into master or there is better resolution?
Metadata
Metadata
Assignees
Labels
No labels