Skip to content

Commit 133c427

Browse files
committed
python 3
1 parent 55e68fd commit 133c427

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

‎setup.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@
88

99
long_description = open('README.rst').read()
1010

11+
unit = 'unittest2py3k' if sys.version_info > (3, 0, 0) else 'unittest2'
1112
tests_require = [
1213
'mock',
1314
'pep8',
14-
'unittest2',
15+
unit,
1516
'pytest',
1617
]
1718

19+
1820
install_requires = [
1921
'requests>=2.3.0',
2022
]
2123

2224

25+
26+
2327
class PyTest(TestCommand):
2428

2529
def finalize_options(self):

‎stream/signing.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
import base64
44

55

6+
def force_str(value):
7+
if hasattr(value, 'encode'):
8+
return value.encode('utf8')
9+
else:
10+
return value
11+
12+
613
def b64_encode(s):
714
return base64.urlsafe_b64encode(s).strip(b'=')
815

@@ -19,6 +26,6 @@ def sign(secret, value):
1926
2027
'''
2128
key = hashlib.sha1((secret).encode('utf-8')).digest()
22-
signed = hmac.new(key, msg=str(value), digestmod=hashlib.sha1)
29+
signed = hmac.new(key, msg=force_str(value), digestmod=hashlib.sha1)
2330
signature = b64_encode(signed.digest())
24-
return str(signature)
31+
return force_str(signature)

‎stream/tests.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class ClientTest(TestCase):
1010
def setUp(self):
1111
# DEBUG account details
1212
self.c = stream.connect(
13-
'5crf3bhfzesn',
14-
'tfq2sdqpj9g446sbv653x3aqmgn33hsn8uzdc9jpskaw8mj6vsnhzswuwptuj9su'
13+
u'5crf3bhfzesn',
14+
u'tfq2sdqpj9g446sbv653x3aqmgn33hsn8uzdc9jpskaw8mj6vsnhzswuwptuj9su'
1515
)
1616
self.user1 = self.c.feed('user:1')
1717
self.aggregated2 = self.c.feed('aggregated:2')
@@ -54,13 +54,13 @@ def test_flat_follow(self):
5454
def _get_first_aggregated_activity(self, activities):
5555
try:
5656
return activities[0]['activities'][0]
57-
except IndexError, e:
57+
except IndexError as e:
5858
pass
5959

6060
def _get_first_activity(self, activities):
6161
try:
6262
return activities[0]
63-
except IndexError, e:
63+
except IndexError as e:
6464
pass
6565

6666
def test_unfollow(self):

0 commit comments

Comments
 (0)