Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

allow unicode URLs on Python 2

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 5850b1f, ca2ebc5 · Browse files · 2 files+10 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−2 removed

  • other:+10 added−2 removed

2 files+10 added−2 removed

modified:requests/models.py+2 added-2 removed
336 unmodified lines
337 #: We're unable to blindy call unicode/str functions338 #: as this will include the bytestring indicator (b'')339 #: on python 3.x.340 #: https://github.com/kennethreitz/requests/pull/2238341 try:341 if isinstance(url, bytes):342 url = url.decode('utf8')343 except AttributeError:343 else:344 url = unicode(url) if is_py2 else str(url)345346 # Don't do any URL preparation for non-HTTP schemes like `mailto`,347 # `data` etc to work around exceptions from `url_parse`, which
486 unmodified lines
modified:test_requests.py+8 added
1505 unmodified lines
1506 cookies={'foo': 'bar'}1507 )1508 assert_copy(p, p.copy())15091510def test_prepare_unicode_url():1511 p = PreparedRequest()1512 p.prepare(1513 method='GET',1514 url=u('http://www.example.com/üniçø∂é')1515 )1516 assert_copy(p, p.copy())15171518if __name__ == '__main__':1519 unittest.main()