Created
February 3, 2012 01:32
-
-
Save jessegonzalez/1727080 to your computer and use it in GitHub Desktop.
request issue with unicode?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from requests import get | |
def func(endpoint, dictionary): | |
resp = get(endpoint, headers=dictionary) | |
print(resp.status_code) | |
if __name__ == "__main__": | |
my_unicode_dict = {u'foo': u'bar'} | |
my_other_dict = {'foo': 'bar'} | |
func("http://www.google.com", my_other_dict) | |
func("http://www.google.com", my_unicode_dict) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python test.py | |
200 | |
Traceback (most recent call last): | |
File "test.py", line 15, in <module> | |
func("http://www.google.com", my_unicode_dict) | |
File "test.py", line 7, in func | |
resp = get(endpoint, headers=dictionary) | |
File "/Users/jesse.gonzalez/Envs/authmonitor/lib/python2.7/site-packages/requests/api.py", line 51, in get | |
return request('get', url, **kwargs) | |
File "/Users/jesse.gonzalez/Envs/authmonitor/lib/python2.7/site-packages/requests/api.py", line 39, in request | |
return s.request(method=method, url=url, **kwargs) | |
File "/Users/jesse.gonzalez/Envs/authmonitor/lib/python2.7/site-packages/requests/sessions.py", line 159, in request | |
headers[k] = header_expand(v) | |
File "/Users/jesse.gonzalez/Envs/authmonitor/lib/python2.7/site-packages/requests/utils.py", line 152, in header_expand | |
for i, (value, params) in enumerate(headers): | |
ValueError: need more than 1 value to unpack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment