Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not support pickle serialized object #111

Open
baojiweicn opened this issue Mar 14, 2017 · 0 comments
Open

Not support pickle serialized object #111

baojiweicn opened this issue Mar 14, 2017 · 0 comments

Comments

@baojiweicn
Copy link

When I use 'get' method to get a serialized string from redis :

  val = await redis_connection.get(key)
  File "/usr/local/lib/python3.6/site-packages/asyncio_redis/protocol.py", line 678, in wrapper
    result = yield from post_process(protocol_self, result)
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/usr/local/lib/python3.6/site-packages/asyncio_redis/protocol.py", line 406, in bytes_to_native_or_none
    return protocol.decode_to_native(result)
  File "/usr/local/lib/python3.6/site-packages/asyncio_redis/encoders.py", line 69, in decode_to_native
    return data.decode(self.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte 

the serialized string like this :

127.0.0.1:6379> get "oe-session:e1759fc0587fbb933b0cf2422a397b73f2fa6d01"
"\x80\x04\x95M\x00\x00\x00\x00\x00\x00\x00}\x94(\x8c\x05login\x94N\x8c\bpassword\x94N\x8c\x02db\x94\x8c\bethicall\x94\x8c\x03uid\x94N\x8c\acontext\x94}\x94\x8c\x04lang\x94\x8c\x05zh_CN\x94su."

unserialized :

In [4]: from cPickle import loads, dump
In [5]: loads('\x80\x02}q\x01(U\x05loginq\x02NU\x08passwordq\x03NU\x02dbq\x04X\x08\x00\x00\x00ethicallq\x05U\x03uidq\x06NU\x07contextq\x07}q\x08U\x04langq\tU\x05zh_CNq\nsu.')
Out[5]: 
{'context': {'lang': 'zh_CN'},
 'db': u'ethicall',
 'login': None,
 'password': None,
 'uid': None}

fortunately, when I use set it works:

await redis_connection.setex('oe-session:e1759fc0587fbb933b0cf2422a397b73f2fa6d01', 
2592000, 
'\x80\x02}q\x01(U\x05loginq\x02NU\x08passwordq\x03NU\x02dbq\x04X\x08\x00\x00\x00ethicallq\x05U\x03uidq\x06NU\x07contextq\x07}q\x08U\x04langq\tU\x05zh_CNq\nsu.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant