[Python-Dev] urllib.quote and unicode bug resuscitation attempt
Mike Brown
mike at skew.org
Sat Jul 15 22:27:15 CEST 2006
Stefan Rank wrote:
> Well, originally, I would have expected it to return a byte str(ing),
I'd assume unicode in, unicode out, and str in, str out, but since it's
always going to produce ASCII-range characters, it wouldn't matter.
Moot point anyway.
> BUT
> I am now converted and think it is best to raise a TypeError for
> unicode, and leave the encoding decisions to higher level code.
>
> So I'll repeat the "patch" #1, slightly modified::
>
> if isinstance(s, unicode):
> raise TypeError("quote expects an encoded byte string as argument")
>
> Is it safe to assume that code that breaks because of this change was
> already broken?
Yes. The patch seems fine to me, although maybe
if not isinstance(s, str)
would be better?
More information about the Python-Dev
mailing list