-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
Python 3
requirements.txt
requests==1.2.0
requests_oauthlib==0.3.1
Stacktrace:
Traceback (most recent call last):
File "/home/travis/build/ryanmcgrath/twython/test_twython.py", line 293, in test_create_and_destroy_favorite
self.api.create_favorite(id=test_tweet_id)
File "/home/travis/build/ryanmcgrath/twython/twython/twython.py", line 87, in <lambda>
return lambda **kwargs: self._constructFunc(key, deprecated_key, **kwargs)
File "/home/travis/build/ryanmcgrath/twython/twython/twython.py", line 126, in _constructFunc
content = self._request(url, method=fn['method'], params=kwargs)
File "/home/travis/build/ryanmcgrath/twython/twython/twython.py", line 142, in _request
response = func(url, data=params, files=files)
File "/home/travis/virtualenv/python3.3/lib/python3.3/site-packages/requests/sessions.py", line 399, in post
return self.request('POST', url, data=data, **kwargs)
File "/home/travis/virtualenv/python3.3/lib/python3.3/site-packages/requests/sessions.py", line 354, in request
resp = self.send(prep, **send_kwargs)
File "/home/travis/virtualenv/python3.3/lib/python3.3/site-packages/requests/sessions.py", line 455, in send
adapter = self.get_adapter(url=request.url)
File "/home/travis/virtualenv/python3.3/lib/python3.3/site-packages/requests/sessions.py", line 489, in get_adapter
if url.startswith(prefix):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
Alright, so basically, my tests are failing.
It ends up being that when using oauthlib (from requests-oauthlib) in conjunction with requests.. oauthlib actually converts the url being passed to bytes and when requests/sessions.py tries to get the adapter on line 455 (requests 1.2.0) in the get_adapter function, it goes through a forloop and at that point (line 489):
if url.startswith(prefix):url is bytes from oauthlib.oauth1.Client.sign every point before that it's a str (trust me, I did extensive filtering to see where the hell it was getting converted from str to bytes haha)
Where should this be fixed though?
oauthlib.. it should be returningstrfor the url in the sign functionrequests_oauthlib.. after it callsself.client.signfromoauthlib.oauth1.Client.signwe should convertr.urlback to astrbefore sending it torequests
ORrequests.. always converturlto astringet_adapter
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels