diff --git a/test_twython.py b/test_twython.py index c867834..1e706a5 100644 --- a/test_twython.py +++ b/test_twython.py @@ -102,7 +102,7 @@ class TwythonAPITestCase(unittest.TestCase): counter = 0 while counter < 2: counter += 1 - result = search.next() + result = next(search) new_id_str = int(result['id_str']) if counter == 1: prev_id_str = new_id_str diff --git a/twython/streaming/api.py b/twython/streaming/api.py index 1a77ec5..6414020 100644 --- a/twython/streaming/api.py +++ b/twython/streaming/api.py @@ -1,5 +1,5 @@ from .. import __version__ -from ..compat import json +from ..compat import json, is_py3 from ..exceptions import TwythonStreamError from .types import TwythonStreamerTypes @@ -93,7 +93,11 @@ class TwythonStreamer(object): break if line: try: - self.on_success(json.loads(line)) + if not is_py3: + self.on_success(json.loads(line)) + else: + line = line.decode('utf-8') + self.on_success(json.loads(line)) except ValueError: raise TwythonStreamError('Response was not valid JSON, \ unable to decode.')