Skip to content

Commit e8d757a

Browse files
committed
Make python-oauth2 compatible with python3
Final commit to make python-oauth2 py3k compatible.
1 parent b7e9280 commit e8d757a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

oauth2/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def to_unicode(s):
115115
if not isinstance(s, str):
116116
raise TypeError('You are required to pass either unicode or string here, not: %r (%s)' % (type(s), s))
117117
try:
118-
s = s.decode('utf-8')
118+
s = s.encode('utf-8')
119119
except UnicodeDecodeError as le:
120120
raise TypeError('You are required to pass either a unicode object or a utf-8 string here. You passed a Python string object which contained non-utf-8: %r. The UnicodeDecodeError that resulted from attempting to interpret it as utf-8 was: %s' % (s, le,))
121121
return s
@@ -914,7 +914,7 @@ def sign(self, request, consumer, token):
914914
"""Builds the base signature string."""
915915
key, raw = self.signing_base(request, consumer, token)
916916

917-
hashed = hmac.new(key.encode('bytearray'), raw, sha)
917+
hashed = hmac.new(key.encode('utf-8'), raw.encode('utf-8'), sha)
918918

919919
# Calculate the digest base 64.
920920
return binascii.b2a_base64(hashed.digest())[:-1]

0 commit comments

Comments
 (0)