You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By reading the code in memcache.py, I found a encoded question.
In set() founction, It encode to utf8, if the value is six.text_type
def _val_to_store_info(self, val, min_compress_len):
flags = 0
if isinstance(val, six.binary_type):
pass
elif isinstance(val, six.text_type):
val = val.encode('utf-8')
......
but , In get() function, It decoder to unicoder ,only if the six.PY3 is true
def _recv_value(self, server, flags, rlen):
rlen += 2 # include \r\n
buf = server.recv(rlen)
if len(buf) != rlen:
raise _Error("received %d bytes when expecting %d"
% (len(buf), rlen))
if len(buf) == rlen:
buf = buf[:-2] # strip \r\n
if flags & Client._FLAG_COMPRESSED:
buf = self.decompressor(buf)
flags &= ~Client._FLAG_COMPRESSED
if flags == 0:
# Bare string
if six.PY3:
val = buf.decode('utf8')
else:
val = buf
elif flags & Client._FLAG_INTEGER:
val = int(buf)
......
I think we should fix it like this in set() function
def _val_to_store_info(self, val, min_compress_len):
flags = 0
if isinstance(val, six.binary_type):
pass
elif isinstance(val, six.text_type) and six.PY3:
val = val.encode('utf-8')
......
The text was updated successfully, but these errors were encountered:
By reading the code in memcache.py, I found a encoded question.
In set() founction, It encode to utf8, if the value is six.text_type
def _val_to_store_info(self, val, min_compress_len):
flags = 0
if isinstance(val, six.binary_type):
pass
elif isinstance(val, six.text_type):
val = val.encode('utf-8')
......
but , In get() function, It decoder to unicoder ,only if the six.PY3 is true
def _recv_value(self, server, flags, rlen):
rlen += 2 # include \r\n
buf = server.recv(rlen)
if len(buf) != rlen:
raise _Error("received %d bytes when expecting %d"
% (len(buf), rlen))
I think we should fix it like this in set() function
def _val_to_store_info(self, val, min_compress_len):
flags = 0
if isinstance(val, six.binary_type):
pass
elif isinstance(val, six.text_type) and six.PY3:
val = val.encode('utf-8')
......
The text was updated successfully, but these errors were encountered: