From 5a22bf73ccf7fae3d2b10314ce7f8eef067fee7a Mon Sep 17 00:00:00 2001 From: Derek Arnold Date: Sat, 31 Aug 2013 18:05:23 -0500 Subject: [PATCH] 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. --- tweepy/auth.py | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- 2.25.1