Skip to content

Commit ad81e7d

Browse files
committedOct 5, 2017
Properly handle binary data types
1 parent d203836 commit ad81e7d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎tornadoasyncmemcache.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,17 @@ def _set(self, cmd, key, val, expire, callback, cas=None):
294294
# does. Ideally we should be raising an exception here.
295295
val = six.text_type(val).encode('ascii')
296296

297+
if not isinstance(val, six.binary_type):
298+
data = six.text_type(data).encode('ascii')
299+
297300
extra = ''
298301
if cas is not None:
299302
extra += ' ' + cas
300303

301304
fullcmd = (cmd + b' ' + key + b' ' + six.text_type(flags).encode('ascii') +
302305
b' ' + six.text_type(expire).encode('ascii') +
303306
b' ' + six.text_type(len(val)).encode('ascii') + extra +
304-
b'\r\n' + six.text_type(val).encode('ascii'))
307+
b'\r\n' + val)
305308

306309
response = server.send_cmd(fullcmd, callback=partial(
307310
self._set_send_cb, server=server, callback=callback))

0 commit comments

Comments
 (0)
Please sign in to comment.