diff --git a/requests/models.py b/requests/models.py index 104b6db7..8885569a 100644 --- a/requests/models.py +++ b/requests/models.py @@ -346,7 +346,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): ]) try: - length = super_len(data) + length = str(super_len(data)) except (TypeError, AttributeError): length = False diff --git a/test_requests.py b/test_requests.py index 4a709827..425e3570 100644 --- a/test_requests.py +++ b/test_requests.py @@ -9,6 +9,12 @@ import unittest import requests from requests.auth import HTTPDigestAuth +from requests.compat import str + +try: + import StringIO +except ImportError: + import io as StringIO HTTPBIN = os.environ.get('HTTPBIN_URL', 'http://httpbin.org/') @@ -131,8 +137,6 @@ class RequestsTestCase(unittest.TestCase): self.assertEqual(r.status_code, 200) def test_BASICAUTH_TUPLE_HTTP_200_OK_GET(self): - - auth = ('user', 'pass') url = httpbin('basic-auth', 'user', 'pass')