Replace convert_to_utf8_str function with str cast
authorHarmon <Harmon758@gmail.com>
Sun, 3 Jan 2021 02:10:16 +0000 (20:10 -0600)
committerHarmon <Harmon758@gmail.com>
Sun, 3 Jan 2021 02:10:16 +0000 (20:10 -0600)
tweepy/binder.py
tweepy/utils.py

index 2a7a2fc52cb82b885cc0f65e91393f95fab372c2..a553a2c04ebeb67397fa81667d732ab905f79b82 100644 (file)
@@ -12,7 +12,6 @@ from urllib.parse import quote, urlencode
 
 from tweepy.error import is_rate_limit_error_message, RateLimitError, TweepError
 from tweepy.models import Model
-from tweepy.utils import convert_to_utf8_str
 
 re_path_template = re.compile(r'{\w+}')
 
@@ -92,7 +91,7 @@ def bind_api(**config):
                 if arg is None:
                     continue
                 try:
-                    self.session.params[self.allowed_param[idx]] = convert_to_utf8_str(arg)
+                    self.session.params[self.allowed_param[idx]] = str(arg)
                 except IndexError:
                     raise TweepError('Too many parameters supplied!')
 
@@ -102,7 +101,7 @@ def bind_api(**config):
                 if k in self.session.params:
                     raise TweepError('Multiple values for parameter %s supplied!' % k)
 
-                self.session.params[k] = convert_to_utf8_str(arg)
+                self.session.params[k] = str(arg)
 
             log.debug("PARAMS: %r", self.session.params)
 
index b1a25155ba981ae30646f402d9d1e16abbe00135..793cf982e7fd2ef533e29cd276cda7e5d6455fe2 100644 (file)
@@ -13,15 +13,6 @@ def parse_a_href(atag):
     return atag[start:end]
 
 
-def convert_to_utf8_str(arg):
-    # written by Michael Norton (http://docondev.blogspot.com/)
-    if isinstance(arg, str):
-        arg = arg.encode('utf-8')
-    elif not isinstance(arg, bytes):
-        arg = str(arg).encode('utf-8')
-    return arg
-
-
 def list_to_csv(item_list):
     if item_list:
         return ','.join(map(str, item_list))