Python 3 compat
This commit is contained in:
parent
c8b1202880
commit
64b1349993
2 changed files with 7 additions and 3 deletions
|
|
@ -102,7 +102,7 @@ class TwythonAPITestCase(unittest.TestCase):
|
||||||
counter = 0
|
counter = 0
|
||||||
while counter < 2:
|
while counter < 2:
|
||||||
counter += 1
|
counter += 1
|
||||||
result = search.next()
|
result = next(search)
|
||||||
new_id_str = int(result['id_str'])
|
new_id_str = int(result['id_str'])
|
||||||
if counter == 1:
|
if counter == 1:
|
||||||
prev_id_str = new_id_str
|
prev_id_str = new_id_str
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from .. import __version__
|
from .. import __version__
|
||||||
from ..compat import json
|
from ..compat import json, is_py3
|
||||||
from ..exceptions import TwythonStreamError
|
from ..exceptions import TwythonStreamError
|
||||||
from .types import TwythonStreamerTypes
|
from .types import TwythonStreamerTypes
|
||||||
|
|
||||||
|
|
@ -93,7 +93,11 @@ class TwythonStreamer(object):
|
||||||
break
|
break
|
||||||
if line:
|
if line:
|
||||||
try:
|
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:
|
except ValueError:
|
||||||
raise TwythonStreamError('Response was not valid JSON, \
|
raise TwythonStreamError('Response was not valid JSON, \
|
||||||
unable to decode.')
|
unable to decode.')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue