Remove comparison between int and str

The code had been doing 'n < self.__in_buffer' when it
wanted to be doing 'n < len(self.__in_buffer)'

In Python 2.x, this comparison (int < str) is always True.
I found this while porting to Python 3 where it raises
an error.

The code has been working without complaints because always
taking the true branch of this conditional is actually fine.
We don't need the false branch, so drop the check entirely.
This commit is contained in:
Bobby Impollonia 2012-03-10 18:10:23 -08:00
parent ece1a825e8
commit 0a013f829e
1 changed files with 2 additions and 6 deletions

View File

@ -62,12 +62,8 @@ class LoopSocket (object):
self.__cv.wait(self.__timeout)
if len(self.__in_buffer) == 0:
raise socket.timeout
if n < self.__in_buffer:
out = self.__in_buffer[:n]
self.__in_buffer = self.__in_buffer[n:]
else:
out = self.__in_buffer
self.__in_buffer = ''
out = self.__in_buffer[:n]
self.__in_buffer = self.__in_buffer[n:]
return out
finally:
self.__lock.release()