Update to 1.4.2, catch for Python 2.5 where urlparse doesn't exist (specifically for Google App Engine, which is strangely still on 2.5

This commit is contained in:
Ryan McGrath 2011-03-30 22:38:07 +09:00
parent 9f8c04b0f2
commit a6d524e79d
2 changed files with 12 additions and 5 deletions

View file

@ -5,7 +5,7 @@ from setuptools import setup
from setuptools import find_packages
__author__ = 'Ryan McGrath <ryan@venodesigns.net>'
__version__ = '1.4.1'
__version__ = '1.4.2'
setup(
# Basic package information.

View file

@ -9,8 +9,9 @@
"""
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
__version__ = "1.4.1"
__version__ = "1.4.2"
import cgi
import urllib
import urllib2
import urlparse
@ -205,7 +206,10 @@ class Twython(object):
if resp['status'] != '200':
raise AuthError("Seems something couldn't be verified with your OAuth junk. Error: %s, Message: %s" % (resp['status'], content))
request_tokens = dict(urlparse.parse_qsl(content))
try:
request_tokens = dict(urlparse.parse_qsl(content))
except:
request_tokens = dict(cgi.parse_qsl(content))
oauth_callback_confirmed = request_tokens.get('oauth_callback_confirmed')=='true'
@ -233,8 +237,11 @@ class Twython(object):
Returns authorized tokens after they go through the auth_url phase.
"""
resp, content = self.client.request(self.access_token_url, "GET")
return dict(urlparse.parse_qsl(content))
try:
return dict(urlparse.parse_qsl(content))
except:
return dict(cgi.parse_qsl(content))
# ------------------------------------------------------------------------------------------------------------------------
# The following methods are all different in some manner or require special attention with regards to the Twitter API.
# Because of this, we keep them separate from all the other endpoint definitions - ideally this should be change-able,