From 2e7b170b1d78de44b3ddf9c343e82e69fbd050e4 Mon Sep 17 00:00:00 2001 From: Sean Reifschneider Date: Wed, 15 Dec 2010 21:31:10 -0700 Subject: Fixing Bug #509712: "TypeError: 'NoneType' object is unsubscriptable" Also fixed some other similar code to not have issues with that. Also added changelog entries for the last two patches. --- memcache.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'memcache.py') diff --git a/memcache.py b/memcache.py index f7bc013..173bf16 100644 --- a/memcache.py +++ b/memcache.py @@ -445,7 +445,7 @@ class Client(local): try: server.send_cmd(cmd) line = server.readline() - if line.strip() =='NOT_FOUND': return None + if line == None or line.strip() =='NOT_FOUND': return None return int(line) except socket.error, msg: if isinstance(msg, tuple): msg = msg[1] @@ -869,7 +869,7 @@ class Client(local): if not line: line = server.readline() - if line[:5] == 'VALUE': + if line and line[:5] == 'VALUE': resp, rkey, flags, len, cas_id = line.split() return (rkey, int(flags), int(len), int(cas_id)) else: @@ -878,10 +878,8 @@ class Client(local): def _expectvalue(self, server, line=None): if not line: line = server.readline() - if not line: - return (None, None, None) - if line[:5] == 'VALUE': + if line and line[:5] == 'VALUE': resp, rkey, flags, len = line.split() flags = int(flags) rlen = int(len) -- cgit v1.2.1