Don't return None from ReadBuffer.read_line and ReadBuffer.read_len
authorAaron Hill <aa1ronham@gmail.com>
Sat, 5 Nov 2016 23:14:01 +0000 (19:14 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Sat, 5 Nov 2016 23:14:01 +0000 (19:14 -0400)
Closes #698

tweepy/streaming.py

index c67047c6fdac87c79da2f9a5ad0b4b0549b44eb6..3d3fb4717e727b6f7162d229d2aafde9cf0b0708 100644 (file)
@@ -162,6 +162,7 @@ class ReadBuffer(object):
                 return self._pop(length)
             read_len = max(self._chunk_size, length - len(self._buffer))
             self._buffer += self._stream.read(read_len)
+        return six.b('')
 
     def read_line(self, sep=six.b('\n')):
         """Read the data stream until a given separator is found (default \n)
@@ -178,6 +179,7 @@ class ReadBuffer(object):
             else:
                 start = len(self._buffer)
             self._buffer += self._stream.read(self._chunk_size)
+        return six.b('')
 
     def _pop(self, length):
         r = self._buffer[:length]
@@ -323,7 +325,7 @@ class Stream(object):
                     raise TweepError('Expecting length, unexpected value found')
 
             next_status_obj = buf.read_len(length)
-            if self.running:
+            if self.running and next_status_obj:
                 self._data(next_status_obj)
 
             # # Note: keep-alive newlines might be inserted before each length value.