Fix AttributeError in OAuth version detection.

Old versions of OAuth didn't have _version attribute, so Twython crashes
on them with AttributeError.

This version first checks if there is _version attribute. If no,
obviously it's an old version.
This commit is contained in:
Edward Hades 2011-09-04 22:59:29 +08:00 committed by Ryan McGrath
parent d6d8823dc2
commit 5a155d4b7c

View file

@ -52,7 +52,7 @@ except ImportError:
# url as part of the request object; older versions we need to patch for Python 2.5... ugh. ;P
OAUTH_CALLBACK_IN_URL = False
OAUTH_LIB_SUPPORTS_CALLBACK = False
if float(oauth._version.manual_verstr) <= 1.4:
if not hasattr(oauth, '_version') or float(oauth._version.manual_verstr) <= 1.4:
OAUTH_CLIENT_INSPECTION = inspect.getargspec(oauth.Client.request)
try:
OAUTH_LIB_SUPPORTS_CALLBACK = 'callback_url' in OAUTH_CLIENT_INSPECTION.args