From: Matt Giuca Date: Tue, 14 Feb 2012 00:50:02 +0000 (+1100) Subject: Fixed URI re-encoding on Python 3 (Issue #369). X-Git-Tag: v0.10.2~21^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf54f60367199042d56334c9a1e2a75546025933;p=services%2Fpython-requests.git Fixed URI re-encoding on Python 3 (Issue #369). Request.full_url now performs requoting of the path (like it does in Python 2). Request.path_url no longer quotes the already-quoted path (double quoting). Fixed utils.requote_path so it works properly in Python 3. --- diff --git a/requests/models.py b/requests/models.py index b72ac64..dcc51b0 100644 --- a/requests/models.py +++ b/requests/models.py @@ -324,7 +324,7 @@ class Request(object): if isinstance(path, str): path = path.encode('utf-8') - path = requote_path(path) + path = requote_path(path) url = (urlunparse([ scheme, netloc, path, params, query, fragment ])) @@ -352,9 +352,6 @@ class Request(object): if not path: path = '/' - if is_py3: - path = quote(path.encode('utf-8')) - url.append(path) query = p.query diff --git a/requests/utils.py b/requests/utils.py index 0f23a52..a773f10 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -403,6 +403,6 @@ def requote_path(path): This function passes the given path through an unquote/quote cycle to ensure that it is fully and consistently quoted. """ - parts = path.split(b"/") - parts = (quote(unquote(part), safe=b"") for part in parts) - return b"/".join(parts) + parts = path.split("/") + parts = (quote(unquote(part), safe="") for part in parts) + return "/".join(parts)