PythonCharmers/python-future

urllib.parse.unquote may return bytes

Open

#431 geöffnet am 21. Jan. 2019

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (1 zugewiesene Person)Python (327 Forks)batch import
0.19help wanted

Repository-Metriken

Stars
 (1.172 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

In Py3, unquote does not accept bytes: the first line if '%' not in string would throw exception.

However, in Py2, that line will not throw exception and perform the checking.

When there's no %, the return value is the argument. That is, when the argument type is bytes, the return value is bytes, too.

Code snippet excerption from src/future/backports/urllib/parse.py#L515:

def unquote(string):
  if '%' not in string:
    string.split
    return string      # bytes or unicode, depends on argument; Py3 never reach here
  ...
  return ''.join(res)  # unicode

Contributor Guide