PythonCharmers/python-future

urllib.parse.unquote may return bytes

Open

#431 建立於 2019年1月21日

在 GitHub 查看
 (1 留言) (0 反應) (1 負責人)Python (327 fork)batch import
0.19help wanted

倉庫指標

Star
 (1,172 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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

貢獻者指南