urllib.unquote and unicode

Fredrik Lundh fredrik at pythonware.com
Tue Dec 19 04:05:45 EST 2006


George Sakkis wrote:

> The following snippet results in different outcome for (at least) the
> last three major releases:
> 
>>>> import urllib
>>>> urllib.unquote(u'%94')
> 
> # Python 2.3.4
> u'%94'
> 
> # Python 2.4.2
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x94 in position 0:
> ordinal not in range(128)
> 
> # Python 2.5
> u'\x94'
> 
> Is the current version the "right" one or is this function supposed to
> change every other week ?

why are you passing non-ASCII Unicode strings to a function designed for 
fixing up 8-bit strings in the first place?  if you do proper encoding 
before you quote things, it'll work the same way in all Python releases.

</F>




More information about the Python-list mailing list