From: Katsunori SUZUI Date: Wed, 19 Nov 2014 14:49:50 +0000 (+0900) Subject: Modify ReadBuffer for Py3 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=48d2744d7b948f166ebf67796d7fec4c278688a1;p=tweepy.git Modify ReadBuffer for Py3 On my Python 3.4.2 environment, UserStreaming did't work because of an error of bytes-to-str conversion. --- 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]