Message 319396 - Python tracker

Message319396

Author thet
Recipients thet
Date 2018-06-12.18:02:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1528826553.26.0.947875510639.issue33846@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2018-06-12 18:02:33thetsetrecipients: + thet
2018-06-12 18:02:33thetsetmessageid: <1528826553.26.0.947875510639.issue33846@psf.upfronthosting.co.za>
2018-06-12 18:02:33thetlinkissue33846 messages
2018-06-12 18:02:33thetcreate