Skip to content
Myr

Fixed issue #747

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Bound the name builtin_str to __builtin__.str and added another check for this class since the str class was rebound to unicode in compat. This issue was only for Python 2 as well.

authored by Marcus McCurdy · committed by Marcus McCurdy · parent 12328d6 · Browse files · 2 files+5 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−3 removed

  • tests:+2 added−2 removed
  • other:+3 added−1 removed

2 files+5 added−3 removed

modified:requests/models.py+3 added-1 removed
32 unmodified lines
33from .compat import (34 cookielib, urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,35 StringIO, is_py2, chardet, json)3637from __builtin__ import str as builtin_str3839REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)40CONTENT_CHUNK_SIZE = 10 * 10244142class Request(object):
451 unmodified lines
494 else:495 if self.data:496497 body = self._encode_params(self.data)496 if isinstance(self.data, str) or hasattr(self.data, 'read'):498 if isinstance(self.data, str) or isinstance(self.data, builtin_str) or hasattr(self.data, 'read'):499 content_type = None500 else:501 content_type = 'application/x-www-form-urlencoded'502
343 unmodified lines
modified:tests/test_requests.py+2 added-2 removed
972 unmodified lines
973 self.assertEqual(t.get('form'), {'field': 'a, b'})974 self.assertEqual(t.get('files'), files)975976 def test_str_data_content_type(self):977 data = "test string data"977 data = 'test string data'978 r = post(httpbin('post'), data=data)979 t = json.loads(r.text)980 self.assertEqual(t.get('headers').get('Content-Type'), 'text/plain')980 self.assertEqual(t.get('headers').get('Content-Type'), '')981982983if __name__ == '__main__':984 unittest.main()