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.
(cherry picked from commit 0a013f829e
)
This commit is contained in:
parent
bd5c843040
commit
ae3ecbe548
|
@ -62,12 +62,8 @@ class LoopSocket (object):
|
||||||
self.__cv.wait(self.__timeout)
|
self.__cv.wait(self.__timeout)
|
||||||
if len(self.__in_buffer) == 0:
|
if len(self.__in_buffer) == 0:
|
||||||
raise socket.timeout
|
raise socket.timeout
|
||||||
if n < self.__in_buffer:
|
|
||||||
out = self.__in_buffer[:n]
|
out = self.__in_buffer[:n]
|
||||||
self.__in_buffer = self.__in_buffer[n:]
|
self.__in_buffer = self.__in_buffer[n:]
|
||||||
else:
|
|
||||||
out = self.__in_buffer
|
|
||||||
self.__in_buffer = ''
|
|
||||||
return out
|
return out
|
||||||
finally:
|
finally:
|
||||||
self.__lock.release()
|
self.__lock.release()
|
||||||
|
|
Loading…
Reference in New Issue