On 3/7/2012 3:42 AM, Steven D'Aprano wrote:

I *think* he is complaining that some other library -- suds? -- has a
broken test for Unicode, by using:

if type(s) is unicode: ...

instead of

if isinstance(s, unicode): ...

Consequently, when the library passes a unicode *subclass* to the
tounicode function, the "type() is unicode" test fails. That's a bad bug.

   No, that was my bug.

   The library bug, if any, is that you can't apply

        unicode(s, errors='replace')

to a Unicode string. TypeError("Decoding unicode is not supported") is raised. However

        unicode(s)

will accept Unicode input.

The Python documentation
("http://docs.python.org/library/functions.html#unicode";) does not mention this. It is therefore necessary to check the type before
calling "unicode", or catch the undocumented TypeError exception
afterward.


                                        John Nagle

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to