<p dir="auto">I'm using requests 2.11.1. The following code throws an exception:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from requests import Request, Session
from http.cookiejar import CookieJar

cj = CookieJar()
req = Request('GET', 'http://google.com', cookies=cj).prepare()
resp = Session().send(req)"><pre class="notranslate"><code class="notranslate">from requests import Request, Session
from http.cookiejar import CookieJar

cj = CookieJar()
req = Request('GET', 'http://google.com', cookies=cj).prepare()
resp = Session().send(req)
</code></pre></div>
<p dir="auto">The exception is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;test.py&quot;, line 6, in &lt;module&gt;
    resp = Session().send(req)
  File &quot;C:\Anaconda3\lib\site-packages\requests\sessions.py&quot;, line 617, in send
    history = [resp for resp in gen] if allow_redirects else []
  File &quot;C:\Anaconda3\lib\site-packages\requests\sessions.py&quot;, line 617, in &lt;listcomp&gt;
    history = [resp for resp in gen] if allow_redirects else []
  File &quot;C:\Anaconda3\lib\site-packages\requests\sessions.py&quot;, line 159, in resolve_redirects
    prepared_request._cookies.update(self.cookies)
AttributeError: 'CookieJar' object has no attribute 'update'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "test.py", line 6, in &lt;module&gt;
    resp = Session().send(req)
  File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 617, in send
    history = [resp for resp in gen] if allow_redirects else []
  File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 617, in &lt;listcomp&gt;
    history = [resp for resp in gen] if allow_redirects else []
  File "C:\Anaconda3\lib\site-packages\requests\sessions.py", line 159, in resolve_redirects
    prepared_request._cookies.update(self.cookies)
AttributeError: 'CookieJar' object has no attribute 'update'
</code></pre></div>
<p dir="auto">I'm able to avoid this by using <code class="notranslate">Session.prepare_request</code> or by passing the cookies via <code class="notranslate">Session.cookies</code>.</p>
<p dir="auto">Duplicate bug disclaimer: this is related to other Unicode + header issues, however, those all focus on errors raised while generating an outbound request. This applies only to inbound requests. (See also: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="9640819" data-permission-text="Title is private" data-url="https://github.com/psf/requests/issues/1082" data-hovercard-type="issue" data-hovercard-url="/psf/requests/issues/1082/hovercard" href="https://github.com/psf/requests/issues/1082">#1082</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3014651" data-permission-text="Title is private" data-url="https://github.com/psf/requests/issues/400" data-hovercard-type="issue" data-hovercard-url="/psf/requests/issues/400/hovercard" href="https://github.com/psf/requests/issues/400">#400</a>, and to a lesser extent, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2984778" data-permission-text="Title is private" data-url="https://github.com/psf/requests/issues/390" data-hovercard-type="pull_request" data-hovercard-url="/psf/requests/pull/390/hovercard" href="https://github.com/psf/requests/pull/390">#390</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3097302" data-permission-text="Title is private" data-url="https://github.com/psf/requests/issues/409" data-hovercard-type="pull_request" data-hovercard-url="/psf/requests/pull/409/hovercard" href="https://github.com/psf/requests/pull/409">#409</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3189528" data-permission-text="Title is private" data-url="https://github.com/psf/requests/issues/421" data-hovercard-type="issue" data-hovercard-url="/psf/requests/issues/421/hovercard" href="https://github.com/psf/requests/issues/421">#421</a>, and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3209519" data-permission-text="Title is private" data-url="https://github.com/psf/requests/issues/424" data-hovercard-type="issue" data-hovercard-url="/psf/requests/issues/424/hovercard" href="https://github.com/psf/requests/issues/424">#424</a>; if this is already covered by another bug, sorry for bugging you guys. Thanks!)</p>
<p dir="auto">When inspecting responses with Unicode-encoded non-latin content trailing the HTTP status header in the response, requests raises UnicodeDecodeError.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="(requests) marmida@loquat:~$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import requests
&gt;&gt;&gt; resp = requests.get('http://jp.apps.gree.net/ja/1604')
&gt;&gt;&gt; resp.ok                                                                                                      
Traceback (most recent call last):                                                                               
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;                                                                            
  File &quot;/home/marmida/venvs/requests/local/lib/python2.7/site-packages/requests/models.py&quot;, line 623, in ok      
    self.raise_for_status()                                                                                      
  File &quot;/home/marmida/venvs/requests/local/lib/python2.7/site-packages/requests/models.py&quot;, line 837, in raise_for_status                                                                                                         
    http_error_msg = '%s Server Error: %s for url: %s' % (self.status_code, self.reason, self.url)               
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 23: ordinal not in range(128)"><pre class="notranslate"><code class="notranslate">(requests) marmida@loquat:~$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import requests
&gt;&gt;&gt; resp = requests.get('http://jp.apps.gree.net/ja/1604')
&gt;&gt;&gt; resp.ok                                                                                                      
Traceback (most recent call last):                                                                               
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;                                                                            
  File "/home/marmida/venvs/requests/local/lib/python2.7/site-packages/requests/models.py", line 623, in ok      
    self.raise_for_status()                                                                                      
  File "/home/marmida/venvs/requests/local/lib/python2.7/site-packages/requests/models.py", line 837, in raise_for_status                                                                                                         
    http_error_msg = '%s Server Error: %s for url: %s' % (self.status_code, self.reason, self.url)               
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 23: ordinal not in range(128)
</code></pre></div>
<p dir="auto">The content causing the problem, fetched via curl:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ curl -v 'http://jp.apps.gree.net/ja/1604' 
* Connected to jp.apps.gree.net (116.93.155.51) port 80 (#0)
&gt; GET /ja/1604 HTTP/1.1
&gt; Host: jp.apps.gree.net
&gt; User-Agent: curl/7.43.0
&gt; Accept: */*
&gt; 
&lt; HTTP/1.1 503 AKB48ステージファイター
&lt; Server: nginx"><pre class="notranslate"><code class="notranslate">$ curl -v 'http://jp.apps.gree.net/ja/1604' 
* Connected to jp.apps.gree.net (116.93.155.51) port 80 (#0)
&gt; GET /ja/1604 HTTP/1.1
&gt; Host: jp.apps.gree.net
&gt; User-Agent: curl/7.43.0
&gt; Accept: */*
&gt; 
&lt; HTTP/1.1 503 AKB48ステージファイター
&lt; Server: nginx
</code></pre></div>
<p dir="auto">In the stack trace above, formatting <code class="notranslate">http_error_msg</code> as a <code class="notranslate">string</code> won't work, because <code class="notranslate">self.reason</code> contains non-ascii <code class="notranslate">unicode</code>.</p>
<p dir="auto">Requests version: 2.9.1<br>
Run from a fresh virtualenv with only <code class="notranslate">requests</code> installed.</p>