PythonCharmers/python-future

urllib.parse.unquote may return bytes

Open

#431 aberto em 21 de jan. de 2019

Ver no GitHub
 (1 comment) (0 reactions) (1 assignee)Python (327 forks)batch import
0.19help wanted

Métricas do repositório

Stars
 (1.172 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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

Guia do colaborador