From edc68a0ac899785cd89a726e3da258e880d641dd Mon Sep 17 00:00:00 2001 From: Alex Khomchenko Date: Fri, 23 Oct 2015 15:22:36 +0300 Subject: [PATCH] fix issue #2844 --- requests/models.py | 2 +- test_requests.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/requests/models.py b/requests/models.py index 2727bee9..639565cf 100644 --- a/requests/models.py +++ b/requests/models.py @@ -81,7 +81,7 @@ class RequestEncodingMixin(object): """ if isinstance(data, (str, bytes)): - return data + return to_native_string(data) elif hasattr(data, 'read'): return data elif hasattr(data, '__iter__'): diff --git a/test_requests.py b/test_requests.py index c5ac4f8d..7b23e594 100755 --- a/test_requests.py +++ b/test_requests.py @@ -139,6 +139,11 @@ class RequestsTestCase(unittest.TestCase): prep = session.prepare_request(request) assert prep.url == 'http://example.com/?z=1&a=1&k=1&d=1' + def test_params_bytes_are_encoded(self): + request = requests.Request('GET', 'http://example.com', + params=b'test=foo').prepare() + assert request.url == 'http://example.com/?test=foo' + def test_mixed_case_scheme_acceptable(self): s = requests.Session() s.proxies = getproxies()