Check consumer key and secret type when initializing OAuthHandler
authorHarmon <Harmon758@gmail.com>
Wed, 30 Dec 2020 06:29:21 +0000 (00:29 -0600)
committerHarmon <Harmon758@gmail.com>
Wed, 30 Dec 2020 06:29:21 +0000 (00:29 -0600)
Resolves #1489

tweepy/auth.py

index 1d138bdc729bf42355df117882dd340f733677bf..7cdd010fc85ad9d2071a6252ec15056c2608881c 100644 (file)
@@ -36,6 +36,13 @@ class OAuthHandler(AuthHandler):
     OAUTH_ROOT = '/oauth/'
 
     def __init__(self, consumer_key, consumer_secret, callback=None):
+        if not isinstance(consumer_key, (str, bytes)):
+            raise TypeError("Consumer key must be string or bytes, not "
+                            + type(consumer_key).__name__)
+        if not isinstance(consumer_secret, (str, bytes)):
+            raise TypeError("Consumer secret must be string or bytes, not "
+                            + type(consumer_secret).__name__)
+
         self.consumer_key = consumer_key
         self.consumer_secret = consumer_secret
         self.access_token = None