From: Derek Arnold Date: Sat, 31 Aug 2013 23:05:23 +0000 (-0500) Subject: Add unicode type detection for consumer key/secret X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5a22bf73ccf7fae3d2b10314ce7f8eef067fee7a;p=tweepy.git Add unicode type detection for consumer key/secret The hmac module won't accept unicode objects so cast them before using them if they're present. --- diff --git a/tweepy/auth.py b/tweepy/auth.py index e545883..123ada5 100644 --- a/tweepy/auth.py +++ b/tweepy/auth.py @@ -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