From ce744c5fa7dd0d4781e39c5750cafc6c32407e15 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Wed, 14 Oct 2009 17:18:05 -0500 Subject: [PATCH] Only utf-8 encode unicode parameters in binder. --- tweepy/binder.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tweepy/binder.py b/tweepy/binder.py index 8000c32..5728962 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -44,9 +44,10 @@ def bind_api(path, parser, allowed_param=[], method='GET', require_auth=False, if allowed_param: parameters = {} for idx, arg in enumerate(args): - encoded_arg = arg.encode('utf-8') # must encode parameters to utf-8 + if isinstance(arg, unicode): + arg = arg.encode('utf-8') try: - parameters[allowed_param[idx]] = encoded_arg + parameters[allowed_param[idx]] = arg except IndexError: raise TweepError('Too many parameters supplied!') for k, arg in kargs.items(): @@ -56,7 +57,9 @@ def bind_api(path, parser, allowed_param=[], method='GET', require_auth=False, raise TweepError('Multiple values for parameter %s supplied!' % k) if k not in allowed_param: raise TweepError('Invalid parameter %s supplied!' % k) - parameters[k] = arg.encode('utf-8') + if isinstance(arg, unicode): + arg = arg.encode('utf-8') + parameters[k] = arg else: if len(args) > 0 or len(kargs) > 0: raise TweepError('This method takes no parameters!') -- 2.25.1