From eab12fa0293ccd5b422bbf23bda2d0993ee4d0f6 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Thu, 7 Apr 2016 08:43:38 +0100 Subject: [PATCH] Fixup Python 3 test failures. --- requests/sessions.py | 4 ++-- test_requests.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requests/sessions.py b/requests/sessions.py index ca4fee8b..7f92fd71 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -136,8 +136,8 @@ class SessionRedirectMixin(object): # urlparse in requote_uri will encode it with UTF-8 before quoting. # Because of this insanity, we need to fix it up ourselves by # sending the URL back to bytes ourselves. - if is_py3 and isinstance(url, str): - url = url.encode('latin1') + if is_py3 and isinstance(location_url, str): + location_url = location_url.encode('latin1') # Facilitate relative 'location' headers, as allowed by RFC 7231. # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource') diff --git a/test_requests.py b/test_requests.py index c62504e6..387276f4 100755 --- a/test_requests.py +++ b/test_requests.py @@ -1653,7 +1653,7 @@ class TestRedirects: assert session.calls[-1] == send_call @pytest.mark.skipif(is_py2, reason="requires python 3") - def test_redirects_with_latin1_header(self): + def test_redirects_with_latin1_header(self, httpbin): """Test that redirect headers decoded with Latin 1 are correctly followed""" session = RedirectSession([303])