Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_cookies_from_headers breaks on Python 2 if python-future is installed #330

Closed
0x9fff00 opened this issue Jun 15, 2020 · 2 comments · Fixed by #435
Closed

_cookies_from_headers breaks on Python 2 if python-future is installed #330

0x9fff00 opened this issue Jun 15, 2020 · 2 comments · Fixed by #435
Assignees

Comments

@0x9fff00
Copy link

0x9fff00 commented Jun 15, 2020

(I have also reported this at PythonCharmers/python-future#564)

If python-future is installed, the test_cookies_from_headers test fails on Python 2 with the following error:

test_responses.py:1119: in test_cookies_from_headers
    cookiejar = responses._cookies_from_headers(headers)
responses.py:122: in _cookies_from_headers
    resp_cookie.load(headers["set-cookie"])
/usr/lib/python2.7/Cookie.py:643: in load
    for k, v in rawdata.items():
E   AttributeError: 'unicode' object has no attribute 'items'

This happens because python-future provides a http.cookies module which just imports the Python 2 Cookie module which doesn't support Unicode strings (see PythonCharmers/python-future#564 for more information). The _cookies_from_headers function uses the Python 3 code path because a http.cookies module is available, but it fails because it doesn't support Unicode strings.

@beliaev-maksim
Copy link
Collaborator

@0x9fff00
can you check if #435 solves it for you?

markstory pushed a commit that referenced this issue Nov 11, 2021
@0x9fff00
Copy link
Author

I can confirm that it's solved, thanks!

@beliaev-maksim beliaev-maksim self-assigned this Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants