From f0db93c59ea29b2d6e9ef626ed535c4ab1c0e2d9 Mon Sep 17 00:00:00 2001 From: Sam Mellor Date: Wed, 30 Jan 2013 01:00:32 +1100 Subject: [PATCH] updated for requests==1.1.0 --- setup.py | 2 +- twython/twython.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 7b4cb5b..ac4d637 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( include_package_data=True, # Package dependencies. - install_requires=['simplejson', 'requests==0.14.0'], + install_requires=['simplejson', 'requests==1.1.0', 'requests_oauthlib==0.3.0'], # Metadata for PyPI. author='Ryan McGrath', diff --git a/twython/twython.py b/twython/twython.py index 49c2f65..ce6931f 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -14,7 +14,7 @@ import re import warnings import requests -from requests.auth import OAuth1 +from requests_oauthlib import OAuth1 try: from urlparse import parse_qsl @@ -115,7 +115,8 @@ class Twython(object): self.headers = headers or {'User-Agent': 'Twython v' + __version__} # Allow for unauthenticated requests - self.client = requests.session(proxies=proxies) + self.client = requests.Session() + self.client.proxies = proxies self.auth = None if self.app_key is not None and self.app_secret is not None and \ @@ -130,7 +131,10 @@ class Twython(object): signature_type='auth_header') if self.auth is not None: - self.client = requests.session(headers=self.headers, auth=self.auth, proxies=proxies) + self.client = requests.Session() + self.client.headers = self.headers + self.client.auth = self.auth + self.client.proxies = proxies # register available funcs to allow listing name when debugging. def setFunc(key): @@ -181,7 +185,6 @@ class Twython(object): 'api_call': api_call, 'api_error': None, 'cookies': response.cookies, - 'error': response.error, 'headers': response.headers, 'status_code': response.status_code, 'url': response.url,