From c054a722bb92d2ed628c22212eed180175e56685 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 25 Jun 2017 12:51:15 -0400 Subject: [PATCH 01/15] Removed legacy fallback for python3.2 --- requests/compat.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/requests/compat.py b/requests/compat.py index 5c09ea88..f417cfd8 100644 --- a/requests/compat.py +++ b/requests/compat.py @@ -27,9 +27,7 @@ is_py3 = (_ver[0] == 3) try: import simplejson as json -except (ImportError, SyntaxError): - # simplejson does not support Python 3.2, it throws a SyntaxError - # because of u'...' Unicode literals. +except ImportError: import json # --------- From e2f5a135c3048d7e6d0b2907ea8811c6943740d3 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Wed, 26 Jul 2017 19:21:45 -0500 Subject: [PATCH 02/15] remove legacy super() call --- requests/models.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/requests/models.py b/requests/models.py index 2148024f..4041cac3 100644 --- a/requests/models.py +++ b/requests/models.py @@ -586,8 +586,6 @@ class Response(object): ] def __init__(self): - super(Response, self).__init__() - self._content = False self._content_consumed = False self._next = None From 39b121d791ddd2f98ecf7b7f7ba5bae89034e422 Mon Sep 17 00:00:00 2001 From: Alex Chan Date: Sat, 8 Jul 2017 11:50:40 +0100 Subject: [PATCH 03/15] Add idna version info to requests.help --- requests/help.py | 5 +++++ tests/test_help.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/requests/help.py b/requests/help.py index cd961c78..5440ee61 100644 --- a/requests/help.py +++ b/requests/help.py @@ -6,6 +6,7 @@ import platform import sys import ssl +import idna import urllib3 import chardet @@ -84,6 +85,9 @@ def info(): cryptography_info = { 'version': getattr(cryptography, '__version__', ''), } + idna_info = { + 'version': getattr(idna, '__version__', ''), + } # OPENSSL_VERSION_NUMBER doesn't exist in the Python 2.6 ssl module. system_ssl = getattr(ssl, 'OPENSSL_VERSION_NUMBER', None) @@ -100,6 +104,7 @@ def info(): 'urllib3': urllib3_info, 'chardet': chardet_info, 'cryptography': cryptography_info, + 'idna': idna_info, 'requests': { 'version': requests_version, }, diff --git a/tests/test_help.py b/tests/test_help.py index f08fdd97..c11d43f3 100644 --- a/tests/test_help.py +++ b/tests/test_help.py @@ -19,3 +19,22 @@ def test_system_ssl_py26(): def test_system_ssl(): """Verify we're actually setting system_ssl when it should be available.""" assert info()['system_ssl']['version'] != '' + + +class VersionedPackage(object): + def __init__(self, version): + self.__version__ = version + + +def test_idna_without_version_attribute(mocker): + """Older versions of IDNA don't provide a __version__ attribute, verify + that if we have such a package, we don't blow up. + """ + mocker.patch('requests.help.idna', new=None) + assert info()['idna'] == {'version': ''} + + +def test_idna_with_version_attribute(mocker): + """Verify we're actually setting idna version when it should be available.""" + mocker.patch('requests.help.idna', new=VersionedPackage('2.6')) + assert info()['idna'] == {'version': '2.6'} From d6b57c6fb25df19aa6fc376e3c2908afa2e3fe46 Mon Sep 17 00:00:00 2001 From: Alex Chan Date: Sat, 8 Jul 2017 11:52:18 +0100 Subject: [PATCH 04/15] Changelog entry --- HISTORY.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 4c6bc740..0fe72a22 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,8 @@ dev **Improvements** +- Running ``$ python -m requests.help`` now includes the installed version of idna. + **Bugfixes** 2.18.2 (2017-07-25) From 8b3f20ca9157f77c6a20bf9b29bba86fec3b04df Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Sat, 29 Jul 2017 12:09:04 +0100 Subject: [PATCH 05/15] Add failing test for #4209 --- tests/test_requests.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_requests.py b/tests/test_requests.py index cfafc6e4..7ef6bfee 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -23,7 +23,7 @@ from requests.cookies import ( from requests.exceptions import ( ConnectionError, ConnectTimeout, InvalidSchema, InvalidURL, MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects, - ProxyError, InvalidHeader, UnrewindableBodyError) + ProxyError, InvalidHeader, UnrewindableBodyError, SSLError) from requests.models import PreparedRequest from requests.structures import CaseInsensitiveDict from requests.sessions import SessionRedirectMixin @@ -812,6 +812,15 @@ class TestRequests: item.category.__name__ for item in warning_records) assert warnings_category == warnings_expected + def test_certificate_failure(self, httpbin_secure): + """ + When underlying SSL problems occur, an SSLError is raised. + """ + with pytest.raises(SSLError): + # Our local httpbin does not have a trusted CA, so this call will + # fail if we use our default trust bundle. + requests.get(httpbin_secure('status', '200')) + def test_urlencoded_get_query_multivalued_param(self, httpbin): r = requests.get(httpbin('get'), params=dict(test=['foo', 'baz'])) From 4f49f6b3ed99cf73feaec762f96f44574ac54134 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Sat, 29 Jul 2017 12:12:11 +0100 Subject: [PATCH 06/15] Correctly raise SSLError from urllib3. --- requests/adapters.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/requests/adapters.py b/requests/adapters.py index 205da0cd..00f8792b 100644 --- a/requests/adapters.py +++ b/requests/adapters.py @@ -501,6 +501,10 @@ class HTTPAdapter(BaseAdapter): if isinstance(e.reason, _ProxyError): raise ProxyError(e, request=request) + if isinstance(e.reason, _SSLError): + # This branch is for urllib3 v1.22 and later. + raise SSLError(e, request=request) + raise ConnectionError(e, request=request) except ClosedPoolError as e: @@ -511,6 +515,7 @@ class HTTPAdapter(BaseAdapter): except (_SSLError, _HTTPError) as e: if isinstance(e, _SSLError): + # This branch is for urllib3 versions earlier than v1.22 raise SSLError(e, request=request) elif isinstance(e, ReadTimeoutError): raise ReadTimeout(e, request=request) From 9e0fb37fff4ad0a9a51ed6b522d2eb47f678d9a3 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Sat, 29 Jul 2017 12:13:55 +0100 Subject: [PATCH 07/15] Changelog for #4209 --- HISTORY.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 0fe72a22..d3ad234e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,9 @@ dev **Bugfixes** +- Fixed issue where Requests would raise ``ConnectionError`` instead of + ``SSLError`` when encoutering SSL problems when using urllib3 v1.22. + 2.18.2 (2017-07-25) +++++++++++++++++++ From 7c67c4adf9020fe6e279f1633ca477ef2b89ae44 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Wed, 2 Aug 2017 14:22:44 +0100 Subject: [PATCH 08/15] v2.18.3 --- HISTORY.rst | 4 ++-- requests/__version__.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index d3ad234e..349e13db 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,8 +3,8 @@ Release History --------------- -dev -+++ +2.18.3 (2017-08-02) ++++++++++++++++++++ **Improvements** diff --git a/requests/__version__.py b/requests/__version__.py index 156ff20a..2d60bcc0 100644 --- a/requests/__version__.py +++ b/requests/__version__.py @@ -5,8 +5,8 @@ __title__ = 'requests' __description__ = 'Python HTTP for Humans.' __url__ = 'http://python-requests.org' -__version__ = '2.18.2' -__build__ = 0x021802 +__version__ = '2.18.3' +__build__ = 0x021803 __author__ = 'Kenneth Reitz' __author_email__ = 'me@kennethreitz.org' __license__ = 'Apache 2.0' From 3393dc822135cb1a08fa4e88dcb883267e3b5716 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Wed, 2 Aug 2017 14:24:02 +0100 Subject: [PATCH 09/15] Prepare changelog for next release --- HISTORY.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 349e13db..870c4358 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,13 @@ Release History --------------- +dev ++++ + +**Improvements** + +**Bugfixes** + 2.18.3 (2017-08-02) +++++++++++++++++++ From be8ce365abf62b1be1450db5c3eae0b845891e7f Mon Sep 17 00:00:00 2001 From: Nik Nyby Date: Wed, 2 Aug 2017 10:26:41 -0400 Subject: [PATCH 10/15] fix typo in changelog --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 870c4358..1c107309 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,7 +20,7 @@ dev **Bugfixes** - Fixed issue where Requests would raise ``ConnectionError`` instead of - ``SSLError`` when encoutering SSL problems when using urllib3 v1.22. + ``SSLError`` when encountering SSL problems when using urllib3 v1.22. 2.18.2 (2017-07-25) +++++++++++++++++++ From f4ddf00c364e4396e7d941f91a8817311dd79adc Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Tue, 8 Aug 2017 13:32:15 +0100 Subject: [PATCH 11/15] Allow IDNA 2.6 --- HISTORY.rst | 4 ++++ setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 1c107309..de6ba5c4 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,10 @@ dev **Bugfixes** +**Dependencies** + +- We now support idna v2.6. + 2.18.3 (2017-08-02) +++++++++++++++++++ diff --git a/setup.py b/setup.py index 98702858..25887bb3 100755 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ packages = ['requests'] requires = [ 'chardet>=3.0.2,<3.1.0', - 'idna>=2.5,<2.6', + 'idna>=2.5,<2.7', 'urllib3>=1.21.1,<1.23', 'certifi>=2017.4.17' From b670b61d544914092504227fb863751f8116e71d Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 8 Aug 2017 19:16:39 -0400 Subject: [PATCH 12/15] Update AUTHORS.rst --- AUTHORS.rst | 7 ------- 1 file changed, 7 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index c5218c6a..b87dc443 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -10,13 +10,6 @@ Keepers of the Four Crystals - Nate Prewitt `@nateprewitt `_ - -Urllib3 -``````` - -- Andrey Petrov - - Patches and Suggestions ``````````````````````` From 963c78853f0125eb21f3483628f34ab322d65b34 Mon Sep 17 00:00:00 2001 From: Nikolaos Vlagoidis Date: Wed, 9 Aug 2017 15:38:45 +0300 Subject: [PATCH 13/15] Fixes issue #3863 --- docs/user/advanced.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index a1b68707..11ee4e3f 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -593,6 +593,10 @@ as using a HTTP one:: 'https': 'socks5://user:pass@host:port' } +Using socks5 proxy resolve domains through the client instead of the proxy server. This is done to be +in line with curl, which uses different schemes to decide whether to resolve via the proxy or via the client. +You need to use the scheme socks5h is you want to resolve domains through the proxy server. + .. _compliance: Compliance From cb9620780ff6c69b88ec0400d3fd140e28a7aec2 Mon Sep 17 00:00:00 2001 From: NikosVlagoidis Date: Wed, 9 Aug 2017 18:52:26 +0300 Subject: [PATCH 14/15] Update advanced.rst --- docs/user/advanced.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 11ee4e3f..742fa4cd 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -593,9 +593,7 @@ as using a HTTP one:: 'https': 'socks5://user:pass@host:port' } -Using socks5 proxy resolve domains through the client instead of the proxy server. This is done to be -in line with curl, which uses different schemes to decide whether to resolve via the proxy or via the client. -You need to use the scheme socks5h is you want to resolve domains through the proxy server. +Using the scheme socks5 causes the DNS resolution to happen on the client, rather than on the proxy server. This is in line with curl, which uses the scheme to decide whether to do the DNS resolution on the client or proxy. If you want to resolve the domains on the proxy server, use socks5h as the scheme. .. _compliance: From 218978601f2ab711ec83e5bd18d439d2c2970efc Mon Sep 17 00:00:00 2001 From: NikosVlagoidis Date: Wed, 9 Aug 2017 20:18:43 +0300 Subject: [PATCH 15/15] Fix issue #3863 --- docs/user/advanced.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 742fa4cd..4aa1dfac 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -593,7 +593,7 @@ as using a HTTP one:: 'https': 'socks5://user:pass@host:port' } -Using the scheme socks5 causes the DNS resolution to happen on the client, rather than on the proxy server. This is in line with curl, which uses the scheme to decide whether to do the DNS resolution on the client or proxy. If you want to resolve the domains on the proxy server, use socks5h as the scheme. +Using the scheme ``socks5`` causes the DNS resolution to happen on the client, rather than on the proxy server. This is in line with curl, which uses the scheme to decide whether to do the DNS resolution on the client or proxy. If you want to resolve the domains on the proxy server, use ``socks5h`` as the scheme. .. _compliance: