Terry J. Reedy added the comment: What about just 's = unicode(s)'? The doc says
"object.__unicode__(self) Called to implement unicode() built-in; should return a Unicode object. When this method is not defined, string conversion is attempted, and the result of string conversion is converted to Unicode using the system default encoding." but the latter part seems not to be true for unicode subclasses. >>> class F(unicode): def __str__(self): raise TypeError() >>> f = F() >>> u = unicode(f) >>> type(u) <type 'unicode'> ---------- stage: -> needs patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23583> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com