Skip to content
Myr

Fixed URI re-encoding on Python 3 (Issue #369).

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

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.

authored by Matt Giuca · committed by Matt Giuca · parent 329efca · Browse files · 2 files+4 added−7 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+4 added−7 removed

  • other:+4 added−7 removed

2 files+4 added−7 removed

modified:requests/models.py+1 added-4 removed
322 unmodified lines
323 if is_py2:324 if isinstance(path, str):325 path = path.encode('utf-8')326327 path = requote_path(path)327 path = requote_path(path)328329 url = (urlunparse([ scheme, netloc, path, params, query, fragment ]))330331 if self._enc_params:
19 unmodified lines
351 path = p.path352 if not path:353 path = '/'354355 if is_py3:356 path = quote(path.encode('utf-8'))357355 url.append(path)356357 query = p.query358 if query:
435 unmodified lines
modified:requests/utils.py+3 added-3 removed
401 unmodified lines
402403 This function passes the given path through an unquote/quote cycle to404 ensure that it is fully and consistently quoted.405 """406 parts = path.split(b"/")407 parts = (quote(unquote(part), safe=b"") for part in parts)408 return b"/".join(parts)406 parts = path.split("/")407 parts = (quote(unquote(part), safe="") for part in parts)408 return "/".join(parts)