[New-bugs-announce] [issue33846] Misleading error message in urllib.parse.unquote

Johannes Raggam report at bugs.python.org
Tue Jun 12 14:02:33 EDT 2018


New submission from Johannes Raggam <thetetet at gmail.com>:

urllib.parse.unquote gives an misleading error message when:

>>> import urllib
>>> urllib.parse.unquote(b'bytesurl')
*** TypeError: a bytes-like object is required, not 'str'

while:

>>> urllib.parse.unquote('texturl')
texturl

The correct behavior is to pass a string/text object to unquote. But passing a bytes object gives a misleading error message.

A fix would be to add an assertion in
https://github.com/python/cpython/blob/0250de48199552cdaed5a4fe44b3f9cdb5325363/Lib/urllib/parse.py#L614 like:

>>> assert isinstance(string, str)

----------
components: Library (Lib)
messages: 319396
nosy: thet
priority: normal
severity: normal
status: open
title: Misleading error message in urllib.parse.unquote
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33846>
_______________________________________


More information about the New-bugs-announce mailing list