From 0e878ce75d7dc8eec312cc06e4e286043e8dcfb0 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Sat, 2 Jan 2010 06:06:20 -0500 Subject: [PATCH] Don't pass odd null parameters for updateStatus(), Twitter has seemingly decided to barf on them --- twython/core.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/twython/core.py b/twython/core.py index 7a664c9..9314abb 100644 --- a/twython/core.py +++ b/twython/core.py @@ -586,12 +586,12 @@ class setup: """ version = version or self.apiVersion try: - return simplejson.load(self.opener.open("http://api.twitter.com/%d/statuses/update.json?" % version, urllib.urlencode({ - "status": self.unicode2utf8(status), - "in_reply_to_status_id": in_reply_to_status_id, - "lat": latitude, - "long": longitude - }))) + postExt = urllib.urlencode({"status": self.unicode2utf8(status)}) + if latitude is not None and longitude is not None: + postExt += "&lat=%s&long=%s" % (latitude, longitude) + if in_reply_to_status_id is not None: + postExt += "&in_reply_to_status_id=%s" % `in_reply_to_status_id` + return simplejson.load(self.opener.open("http://api.twitter.com/%d/statuses/update.json?" % version, postExt)) except HTTPError, e: raise TwythonError("updateStatus() failed with a %s error code." % `e.code`, e.code)