Skip to content
Myr

Merge pull request #3486 from nateprewitt/3481_revert_3362

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

reverting 3362

authored by Cory Benfield · committed by GitHub · parents 5259b37, d7f56ba · Browse files · 2 files+5 added−19 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−19 removed

  • tests:+0 added−7 removed
  • other:+5 added−12 removed

2 files+5 added−19 removed

modified:requests/utils.py+5 added-12 removed
365 unmodified lines
366367368def stream_decode_response_unicode(iterator, r):369 """Stream decodes a iterator."""370 encoding = r.encoding370372 if encoding is None:373 encoding = r.apparent_encoding371 if r.encoding is None:372 for item in iterator:373 yield item374 return375375 try:376 decoder = codecs.getincrementaldecoder(encoding)(errors='replace')376 decoder = codecs.getincrementaldecoder(r.encoding)(errors='replace')377 except (LookupError, TypeError):378 # A LookupError is raised if the encoding was not found which could379 # indicate a misspelling or similar mistake.380 #381 # A TypeError can be raised if encoding is None382 raise UnicodeError("Unable to decode contents with encoding %s." % encoding)383377 for chunk in iterator:378 rv = decoder.decode(chunk)379 if rv:380 yield rv
437 unmodified lines
modified:tests/test_requests.py-7 removed
971 unmodified lines
972 r.encoding = 'ascii'973 chunks = r.iter_content(decode_unicode=True)974 assert all(isinstance(chunk, str) for chunk in chunks)975976 # check for encoding value of None977 r = requests.Response()978 r.raw = io.BytesIO(b'the content')979 r.encoding = None980 chunks = r.iter_content(decode_unicode=True)981 assert all(isinstance(chunk, str) for chunk in chunks)982976 def test_response_reason_unicode(self):977 # check for unicode HTTP status978 r = requests.Response()979 r.url = u'unicode URL'
796 unmodified lines