diff --git a/.travis.yml b/.travis.yml index a938f5ee..20075db2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ sudo: false language: python python: - - "2.6" - "2.7" - "3.3" - "3.4" @@ -10,20 +9,21 @@ python: # - "3.7-dev" # - "pypy" -- appears to hang # - "pypy3" +matrix: + allow_failures: + - python: 3.7-dev # command to install dependencies install: "make" # command to run tests script: - - | - if [[ "$TRAVIS_PYTHON_VERSION" != "2.6" ]] ; then make test-readme; fi + - make test-readme - make ci cache: pip jobs: include: - stage: test script: - - | - if [[ "$TRAVIS_PYTHON_VERSION" != "2.6" ]] ; then make test-readme; fi + - make test-readme - make ci - stage: coverage python: 3.6 diff --git a/3.0-HISTORY.rst b/3.0-HISTORY.rst index 4674579a..31df0ca0 100644 --- a/3.0-HISTORY.rst +++ b/3.0-HISTORY.rst @@ -1,6 +1,8 @@ 3.0.0 (2017-xx-xx) ++++++++++++++++++ +- Support for Python 2.6 has been dropped. + - Simplified logic for determining Content-Length and Transfer-Encoding. Requests will now avoid setting both headers on the same request, and raise an exception if this is done manually by a user. diff --git a/AUTHORS.rst b/AUTHORS.rst index bea78508..832b8fd4 100755 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -128,7 +128,7 @@ Patches and Suggestions - Bryce Boe (`@bboe `_) - Colin Dunklau (`@cdunklau `_) - Bob Carroll (`@rcarz `_) -- Hugo Osvaldo Barrera (`@hobarrera `_) +- Hugo Osvaldo Barrera (`@hobarrera `_) - Łukasz Langa - Dave Shawley - James Clarke (`@jam `_) diff --git a/README.rst b/README.rst index 1dbee794..13fafe4c 100644 --- a/README.rst +++ b/README.rst @@ -81,7 +81,7 @@ Requests is ready for today's web. - ``.netrc`` Support - Chunked Requests -Requests officially supports Python 2.6–2.7 & 3.3–3.7, and runs great on PyPy. +Requests officially supports Python 2.7 & 3.3–3.7, and runs great on PyPy. Installation ------------ diff --git a/docs/community/faq.rst b/docs/community/faq.rst index e835b122..256856ad 100644 --- a/docs/community/faq.rst +++ b/docs/community/faq.rst @@ -54,7 +54,6 @@ Python 3 Support? Yes! Here's a list of Python platforms that are officially supported: -* Python 2.6 * Python 2.7 * Python 3.3 * Python 3.4 @@ -69,7 +68,7 @@ These errors occur when :ref:`SSL certificate verification ` fails to match the certificate the server responds with to the hostname Requests thinks it's contacting. If you're certain the server's SSL setup is correct (for example, because you can visit the site with your browser) and -you're using Python 2.6 or 2.7, a possible explanation is that you need +you're using Python 2.7, a possible explanation is that you need Server-Name-Indication. `Server-Name-Indication`_, or SNI, is an official extension to SSL where the diff --git a/docs/dev/todo.rst b/docs/dev/todo.rst index 88f0073c..0f508caf 100644 --- a/docs/dev/todo.rst +++ b/docs/dev/todo.rst @@ -49,7 +49,6 @@ Runtime Environments Requests currently supports the following versions of Python: -- Python 2.6 - Python 2.7 - Python 3.3 - Python 3.4 diff --git a/docs/index.rst b/docs/index.rst index b17605bb..101e0450 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -104,7 +104,7 @@ Requests is ready for today's web. - Chunked Requests - ``.netrc`` Support -Requests officially supports Python 2.6–2.7 & 3.3–3.7, and runs great on PyPy. +Requests officially supports Python 2.7 & 3.3–3.7, and runs great on PyPy. The User Guide diff --git a/requests/__init__.py b/requests/__init__.py index d4461ec9..c3286724 100644 --- a/requests/__init__.py +++ b/requests/__init__.py @@ -100,12 +100,7 @@ from .exceptions import ( # Set default logging handler to avoid "No handler found" warnings. import logging -try: # Python 2.7+ - from logging import NullHandler -except ImportError: - class NullHandler(logging.Handler): - def emit(self, record): - pass +from logging import NullHandler logging.getLogger(__name__).addHandler(NullHandler()) diff --git a/requests/adapters.py b/requests/adapters.py index 779111d5..b2c1d4e3 100644 --- a/requests/adapters.py +++ b/requests/adapters.py @@ -187,8 +187,7 @@ class HTTPAdapter(BaseAdapter): self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block) def __getstate__(self): - return dict((attr, getattr(self, attr, None)) for attr in - self.__attrs__) + return {attr: getattr(self, attr, None) for attr in self.__attrs__} def __setstate__(self, state): # Can't handle by adding 'proxy_manager' to self.__attrs__ because @@ -478,11 +477,10 @@ class HTTPAdapter(BaseAdapter): # Receive the response from the server try: - # For Python 2.7+ versions, use buffering of HTTP - # responses + # For Python 2.7, use buffering of HTTP responses r = low_conn.getresponse(buffering=True) except TypeError: - # For compatibility with Python 2.6 versions and back + # For Python 3.3+ versions, this is the default r = low_conn.getresponse() resp = HTTPResponse.from_httplib( diff --git a/requests/cookies.py b/requests/cookies.py index 95ad4d57..d4abfd0e 100644 --- a/requests/cookies.py +++ b/requests/cookies.py @@ -440,20 +440,21 @@ def create_cookie(name, value, **kwargs): By default, the pair of `name` and `value` will be set for the domain '' and sent on every request (this is sometimes called a "supercookie"). """ - result = dict( - version=0, - name=name, - value=value, - port=None, - domain='', - path='/', - secure=False, - expires=None, - discard=True, - comment=None, - comment_url=None, - rest={'HttpOnly': None}, - rfc2109=False,) + result = { + 'version': 0, + 'name': name, + 'value': value, + 'port': None, + 'domain': '', + 'path': '/', + 'secure': False, + 'expires': None, + 'discard': True, + 'comment': None, + 'comment_url': None, + 'rest': {'HttpOnly': None}, + 'rfc2109': False, + } badargs = set(kwargs) - set(result) if badargs: diff --git a/requests/hooks.py b/requests/hooks.py index 32b32de7..7a51f212 100644 --- a/requests/hooks.py +++ b/requests/hooks.py @@ -15,14 +15,14 @@ HOOKS = ['response'] def default_hooks(): - return dict((event, []) for event in HOOKS) + return {event: [] for event in HOOKS} # TODO: response is the only one def dispatch_hook(key, hooks, hook_data, **kwargs): """Dispatches a hook dictionary on a given piece of data.""" - hooks = hooks or dict() + hooks = hooks or {} hooks = hooks.get(key) if hooks: if hasattr(hooks, '__call__'): diff --git a/requests/models.py b/requests/models.py index 864baadc..cb20d037 100644 --- a/requests/models.py +++ b/requests/models.py @@ -653,10 +653,7 @@ class Response(object): if not self._content_consumed: self.content - return dict( - (attr, getattr(self, attr, None)) - for attr in self.__attrs__ - ) + return {attr: getattr(self, attr, None) for attr in self.__attrs__} def __setstate__(self, state): for name, value in state.items(): diff --git a/requests/sessions.py b/requests/sessions.py index 629c8148..d485d1f0 100755 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -736,7 +736,7 @@ class Session(SessionRedirectMixin): self.adapters[key] = self.adapters.pop(key) def __getstate__(self): - state = dict((attr, getattr(self, attr, None)) for attr in self.__attrs__) + state = {attr: getattr(self, attr, None) for attr in self.__attrs__} return state def __setstate__(self, state): diff --git a/requests/utils.py b/requests/utils.py index 3a29183e..e619bf09 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -679,22 +679,8 @@ def should_bypass_proxies(url, no_proxy): # to apply the proxies on this URL. return True - # If the system proxy settings indicate that this URL should be bypassed, - # don't proxy. - # The proxy_bypass function is incredibly buggy on OS X in early versions - # of Python 2.6, so allow this call to fail. Only catch the specific - # exceptions we've seen, though: this call failing in other ways can reveal - # legitimate problems. with set_environ('no_proxy', no_proxy_arg): - try: - bypass = proxy_bypass(netloc) - except (TypeError, socket.gaierror): - bypass = False - - if bypass: - return True - - return False + return bool(proxy_bypass(netloc)) def get_environ_proxies(url, no_proxy=None): diff --git a/setup.py b/setup.py index 93a85077..b0e7ddb5 100755 --- a/setup.py +++ b/setup.py @@ -80,7 +80,7 @@ setup( 'Natural Language :: English', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', @@ -95,7 +95,6 @@ setup( extras_require={ 'security': ['pyOpenSSL>=0.14', 'cryptography>=1.3.4', 'idna>=2.0.0'], 'socks': ['PySocks>=1.5.6, !=1.5.7'], - 'socks:sys_platform == "win32" and (python_version == "2.7" or python_version == "2.6")': ['win_inet_pton'], + 'socks:sys_platform == "win32" and python_version == "2.7"': ['win_inet_pton'], }, ) - diff --git a/tests/test_requests.py b/tests/test_requests.py index 08abdeb6..272d3fd4 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -933,7 +933,7 @@ class TestRequests: def test_urlencoded_get_query_multivalued_param(self, httpbin): - r = requests.get(httpbin('get'), params=dict(test=['foo', 'baz'])) + r = requests.get(httpbin('get'), params={'test': ['foo', 'baz']}) assert r.status_code == 200 assert r.url == httpbin('get?test=foo&test=baz') diff --git a/tests/test_utils.py b/tests/test_utils.py index 41858b37..04baad49 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -566,7 +566,7 @@ def test_add_dict_to_cookiejar(cookiejar): cookiedict = {'test': 'cookies', 'good': 'cookies'} cj = add_dict_to_cookiejar(cookiejar, cookiedict) - cookies = dict((cookie.name, cookie.value) for cookie in cj) + cookies = {cookie.name: cookie.value for cookie in cj} assert cookiedict == cookies diff --git a/tox.ini b/tox.ini index 2a961c82..03f069ba 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] -envlist = py26,py27,py33,py34,py35,py36 +envlist = py27,py33,py34,py35,py36 [testenv] commands = pip install -e .[socks] - python setup.py test \ No newline at end of file + python setup.py test