Add unicode type detection for consumer key/secret
authorDerek Arnold <github@vyr.us>
Sat, 31 Aug 2013 23:05:23 +0000 (18:05 -0500)
committerDerek Arnold <github@vyr.us>
Sat, 31 Aug 2013 23:27:27 +0000 (18:27 -0500)
The hmac module won't accept unicode objects so cast them before using
them if they're present.

tweepy/auth.py

index e545883961ccac985aceb327692c6273d9c82cf4..123ada54b911fe21b386283f6cf71442f730507c 100644 (file)
@@ -28,6 +28,12 @@ class OAuthHandler(AuthHandler):
     OAUTH_ROOT = '/oauth/'
 
     def __init__(self, consumer_key, consumer_secret, callback=None, secure=False):
+        if type(consumer_key) == unicode:
+            consumer_key = bytes(consumer_key)
+
+        if type(consumer_secret) == unicode:
+            consumer_secret = bytes(consumer_secret)
+
         self._consumer = oauth.OAuthConsumer(consumer_key, consumer_secret)
         self._sigmethod = oauth.OAuthSignatureMethod_HMAC_SHA1()
         self.request_token = None