From cfd6e25749dd17c6b511043a6720b672f74029ed Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Sat, 25 Oct 2014 13:54:34 +0200 Subject: [PATCH 1/6] fix failing test "test_prepare_unicode_url" --- requests/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/requests/models.py b/requests/models.py index 17e55988..8cc6e3b7 100644 --- a/requests/models.py +++ b/requests/models.py @@ -22,8 +22,8 @@ from .packages.urllib3.util import parse_url from .packages.urllib3.exceptions import ( DecodeError, ReadTimeoutError, ProtocolError) from .exceptions import ( - HTTPError, RequestException, MissingSchema, InvalidURL, - ChunkedEncodingError, ContentDecodingError, ConnectionError, + HTTPError, RequestException, MissingSchema, InvalidURL, + ChunkedEncodingError, ContentDecodingError, ConnectionError, StreamConsumedError) from .utils import ( guess_filename, get_auth_from_url, requote_uri, @@ -511,8 +511,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): def prepare_hooks(self, hooks): """Prepares the given hooks.""" - for event in hooks: - self.register_hook(event, hooks[event]) + if hooks is not None: + for event in hooks: + self.register_hook(event, hooks[event]) class Response(object): From c044a70796f5ba7cbe8f5a4c45a849c3acf09037 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Sat, 25 Oct 2014 13:54:47 +0200 Subject: [PATCH 2/6] update AUTHORS --- AUTHORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index a1b5ec46..71171d08 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -157,3 +157,4 @@ Patches and Suggestions - Martin Jul (`@mjul `_) - Joe Alcorn (`@buttscicles `_) - Syed Suhail Ahmed (`@syedsuhail `_) +- Scott Sadler (`@ssadler `_) From 77687de5099b6b65cde5901a29a3b1c5e751b8a2 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Sun, 26 Oct 2014 12:40:05 +0100 Subject: [PATCH 3/6] Revert "fix failing test "test_prepare_unicode_url"" This reverts commit cfd6e25749dd17c6b511043a6720b672f74029ed. --- requests/models.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/requests/models.py b/requests/models.py index 8cc6e3b7..17e55988 100644 --- a/requests/models.py +++ b/requests/models.py @@ -22,8 +22,8 @@ from .packages.urllib3.util import parse_url from .packages.urllib3.exceptions import ( DecodeError, ReadTimeoutError, ProtocolError) from .exceptions import ( - HTTPError, RequestException, MissingSchema, InvalidURL, - ChunkedEncodingError, ContentDecodingError, ConnectionError, + HTTPError, RequestException, MissingSchema, InvalidURL, + ChunkedEncodingError, ContentDecodingError, ConnectionError, StreamConsumedError) from .utils import ( guess_filename, get_auth_from_url, requote_uri, @@ -511,9 +511,8 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): def prepare_hooks(self, hooks): """Prepares the given hooks.""" - if hooks is not None: - for event in hooks: - self.register_hook(event, hooks[event]) + for event in hooks: + self.register_hook(event, hooks[event]) class Response(object): From 26ed7c2e1dce4271f3a3b111a167a6dcca3acddf Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Sun, 26 Oct 2014 12:49:46 +0100 Subject: [PATCH 4/6] fix failing test "test_prepare_unicode_url" --- requests/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requests/models.py b/requests/models.py index 17e55988..e216efae 100644 --- a/requests/models.py +++ b/requests/models.py @@ -22,8 +22,8 @@ from .packages.urllib3.util import parse_url from .packages.urllib3.exceptions import ( DecodeError, ReadTimeoutError, ProtocolError) from .exceptions import ( - HTTPError, RequestException, MissingSchema, InvalidURL, - ChunkedEncodingError, ContentDecodingError, ConnectionError, + HTTPError, RequestException, MissingSchema, InvalidURL, + ChunkedEncodingError, ContentDecodingError, ConnectionError, StreamConsumedError) from .utils import ( guess_filename, get_auth_from_url, requote_uri, @@ -310,7 +310,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): # such as OAuth to work on a fully prepared request. # This MUST go after prepare_auth. Authenticators could add a hook - self.prepare_hooks(hooks) + self.prepare_hooks(hooks if hooks is not None else []) def __repr__(self): return '' % (self.method) From 8e69c9f0a16b37990df4430eb81a5138520689ac Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Sun, 26 Oct 2014 14:41:56 +0100 Subject: [PATCH 5/6] Revert "fix failing test "test_prepare_unicode_url"" This reverts commit 26ed7c2e1dce4271f3a3b111a167a6dcca3acddf. --- requests/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requests/models.py b/requests/models.py index e216efae..17e55988 100644 --- a/requests/models.py +++ b/requests/models.py @@ -22,8 +22,8 @@ from .packages.urllib3.util import parse_url from .packages.urllib3.exceptions import ( DecodeError, ReadTimeoutError, ProtocolError) from .exceptions import ( - HTTPError, RequestException, MissingSchema, InvalidURL, - ChunkedEncodingError, ContentDecodingError, ConnectionError, + HTTPError, RequestException, MissingSchema, InvalidURL, + ChunkedEncodingError, ContentDecodingError, ConnectionError, StreamConsumedError) from .utils import ( guess_filename, get_auth_from_url, requote_uri, @@ -310,7 +310,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): # such as OAuth to work on a fully prepared request. # This MUST go after prepare_auth. Authenticators could add a hook - self.prepare_hooks(hooks if hooks is not None else []) + self.prepare_hooks(hooks) def __repr__(self): return '' % (self.method) From 583859b8204a1e9dd8a337f1ca06e31e8f79b5f8 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Sun, 26 Oct 2014 14:45:12 +0100 Subject: [PATCH 6/6] fix failing test "test_prepare_unicode_url" \(take 3\) --- test_requests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test_requests.py b/test_requests.py index 0d93893b..467c5bc6 100755 --- a/test_requests.py +++ b/test_requests.py @@ -1511,7 +1511,8 @@ def test_prepare_unicode_url(): p = PreparedRequest() p.prepare( method='GET', - url=u('http://www.example.com/üniçø∂é') + url=u('http://www.example.com/üniçø∂é'), + hooks=[] ) assert_copy(p, p.copy())