From 0a013f829e9eb20fb037a2ac06c230d9074fbe90 Mon Sep 17 00:00:00 2001 From: Bobby Impollonia Date: Sat, 10 Mar 2012 18:10:23 -0800 Subject: [PATCH] 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. --- tests/loop.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/loop.py b/tests/loop.py index 0eac08a..750b889 100644 --- a/tests/loop.py +++ b/tests/loop.py @@ -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()