From 48d2744d7b948f166ebf67796d7fec4c278688a1 Mon Sep 17 00:00:00 2001 From: Katsunori SUZUI Date: Wed, 19 Nov 2014 23:49:50 +0900 Subject: [PATCH] Modify ReadBuffer for Py3 On my Python 3.4.2 environment, UserStreaming did't work because of an error of bytes-to-str conversion. --- tweepy/streaming.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 186d69a..0cf1d7c 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -146,7 +146,7 @@ class ReadBuffer(object): def __init__(self, stream, chunk_size): self._stream = stream - self._buffer = "" + self._buffer = u"" self._chunk_size = chunk_size def read_len(self, length): @@ -154,7 +154,7 @@ class ReadBuffer(object): if len(self._buffer) >= length: return self._pop(length) read_len = max(self._chunk_size, length - len(self._buffer)) - self._buffer += self._stream.read(read_len) + self._buffer += self._stream.read(read_len).decode("ascii") def read_line(self, sep='\n'): start = 0 @@ -164,7 +164,7 @@ class ReadBuffer(object): return self._pop(loc + len(sep)) else: start = len(self._buffer) - self._buffer += self._stream.read(self._chunk_size) + self._buffer += self._stream.read(self._chunk_size).decode("ascii") def _pop(self, length): r = self._buffer[:length] -- 2.25.1