<p dir="auto">we do a post, passing the cookies from the previous response as the cookies:</p>
<p dir="auto">requests.post(...,cookies=resp.cookies...)</p>
<p dir="auto">the request function of the Session class appears to be presuming the cookies are always a dict, even though the comments indicate it could also be a cookiejar.</p>
<p dir="auto">self.cookies = cookiejar_from_dict(cookies, cookiejar=self.cookies, overwrite=False)</p>
<p dir="auto">the only way we can get it to work is if we use:</p>
<p dir="auto">requests.post(...,cookies=resp.cookies.get_dict...)</p>
<p dir="auto">Thanks</p>
<p dir="auto">Could not find an issue raised for this, not sure if this was an expected change either. This is reproducible on master.</p>
<p dir="auto">Existing code fails on update to <code class="notranslate">requests-2.0.1</code>. The cause seems to be triggered by the change at <a class="commit-link" href="https://github.com/kennethreitz/requests/commit/012f0334ce43fe23044fc58e4246a804db88650d#diff-28e67177469c0d36b068d68d9f6043bfR326">kennethreitz@<tt>012f033</tt>#diff-28e67177469c0d36b068d68d9f6043bfR326</a></p>
<p dir="auto">The parameter <code class="notranslate">cookies</code> expects either <code class="notranslate">Dict</code> or <code class="notranslate">CookieJar</code>. Treating <code class="notranslate">MozillaCookieJar</code> as a dict triggers the error in this instance.</p>
<p dir="auto">The following code highlights the issue:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import sys
import requests
from os.path import expanduser

if sys.version_info.major &gt;= 3:
    from http.cookiejar import MozillaCookieJar
else:
    from cookielib import MozillaCookieJar

URL = 'https://bugzilla.redhat.com'
COOKIE_FILE = expanduser('~/.bugzillacookies')

cookiejar = MozillaCookieJar(COOKIE_FILE)
cookiejar.load()

requests.get(URL, cookies=cookiejar)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">sys</span>
<span class="pl-k">import</span> <span class="pl-s1">requests</span>
<span class="pl-k">from</span> <span class="pl-s1">os</span>.<span class="pl-s1">path</span> <span class="pl-k">import</span> <span class="pl-s1">expanduser</span>

<span class="pl-k">if</span> <span class="pl-s1">sys</span>.<span class="pl-s1">version_info</span>.<span class="pl-s1">major</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">3</span>:
    <span class="pl-k">from</span> <span class="pl-s1">http</span>.<span class="pl-s1">cookiejar</span> <span class="pl-k">import</span> <span class="pl-v">MozillaCookieJar</span>
<span class="pl-k">else</span>:
    <span class="pl-k">from</span> <span class="pl-s1">cookielib</span> <span class="pl-k">import</span> <span class="pl-v">MozillaCookieJar</span>

<span class="pl-v">URL</span> <span class="pl-c1">=</span> <span class="pl-s">'https://bugzilla.redhat.com'</span>
<span class="pl-v">COOKIE_FILE</span> <span class="pl-c1">=</span> <span class="pl-en">expanduser</span>(<span class="pl-s">'~/.bugzillacookies'</span>)

<span class="pl-s1">cookiejar</span> <span class="pl-c1">=</span> <span class="pl-v">MozillaCookieJar</span>(<span class="pl-v">COOKIE_FILE</span>)
<span class="pl-s1">cookiejar</span>.<span class="pl-en">load</span>()

<span class="pl-s1">requests</span>.<span class="pl-en">get</span>(<span class="pl-v">URL</span>, <span class="pl-s1">cookies</span><span class="pl-c1">=</span><span class="pl-s1">cookiejar</span>)</pre></div>
<p dir="auto">The following <code class="notranslate">AttributeError</code> is thrown:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;rtest.py&quot;, line 16, in &lt;module&gt;
    requests.get(URL, cookies=cookiejar)
  File &quot;/tmp/rtestenv/lib/python2.7/site-packages/requests/api.py&quot;, line 55, in get
    return request('get', url, **kwargs)
  File &quot;/tmp/rtestenv/lib/python2.7/site-packages/requests/api.py&quot;, line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File &quot;/tmp/rtestenv/lib/python2.7/site-packages/requests/sessions.py&quot;, line 327, in request
    self.cookies = cookiejar_from_dict(cookies, cookiejar=self.cookies, overwrite=False)
  File &quot;/tmp/rtestenv/lib/python2.7/site-packages/requests/cookies.py&quot;, line 410, in cookiejar_from_dict
    cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
AttributeError: MozillaCookieJar instance has no attribute '__getitem__'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "rtest.py", line 16, in &lt;module&gt;
    requests.get(URL, cookies=cookiejar)
  File "/tmp/rtestenv/lib/python2.7/site-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/tmp/rtestenv/lib/python2.7/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/tmp/rtestenv/lib/python2.7/site-packages/requests/sessions.py", line 327, in request
    self.cookies = cookiejar_from_dict(cookies, cookiejar=self.cookies, overwrite=False)
  File "/tmp/rtestenv/lib/python2.7/site-packages/requests/cookies.py", line 410, in cookiejar_from_dict
    cookiejar.set_cookie(create_cookie(name, cookie_dict[name]))
AttributeError: MozillaCookieJar instance has no attribute '__getitem__'
</code></pre></div>