Merge pull request #2267 from minrk/unicode-url-py2

allow unicode URLs on Python 2
This commit is contained in:
2014-10-06 05:39:54 -04:00
2 changed files with 10 additions and 2 deletions
+2 -2
View File
@@ -338,9 +338,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
#: as this will include the bytestring indicator (b'')
#: on python 3.x.
#: https://github.com/kennethreitz/requests/pull/2238
try:
if isinstance(url, bytes):
url = url.decode('utf8')
except AttributeError:
else:
url = unicode(url) if is_py2 else str(url)
# Don't do any URL preparation for non-HTTP schemes like `mailto`,
+8
View File
@@ -1507,5 +1507,13 @@ def test_prepared_request_complete_copy():
)
assert_copy(p, p.copy())
def test_prepare_unicode_url():
p = PreparedRequest()
p.prepare(
method='GET',
url=u('http://www.example.com/üniçø∂é')
)
assert_copy(p, p.copy())
if __name__ == '__main__':
unittest.main()