kennethreitz/requests — pull request #472 by danverbraganza (2012-03-07 01:05:38+00:00)
Title: A fix for https://github.com/kennethreitz/requests/issues/461

Added testcase showing a non-standard unicode character (in this case,
A-umlaut), returned by the server in a redirect, breaks py27 requests.

I have a class of urls which I need to get in py27 which break,
because the server returns a _relative redirect_ with a high unicode
character in it. Because of how str and unicode are re-bound in py_27
mode for requests, this means that unicode is being called on an
object that does not implicitly convert to unicode (it has an ord >
127).

The other minor change I made is a small hack to remove the unicode-literal u from
test_requests_ext.py so it can be run on python3.

This fix, which seems to work for me (hurray), is to urllib.quote the
relative returned by the server. This percent-encodes the non-standard
characters in the unicode, and then everything behaves nicely.

All tests pass for python 2.7.2 and python 3.2.2 on Linux.