This works as expected (this is on an ASCII terminal): >>> unicode('asdf\xff', errors='replace') u'asdf\ufffd'
This does not work as I expect it to: >>> class C: ... def __str__(self): ... return 'asdf\xff' ... >>> o = C() >>> unicode(o, errors='replace') Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: coercing to Unicode: need string or buffer, instance found Shouldn't it work the same as calling unicode(str(self), errors='replace')? It doesn't matter what value you use for 'errors' (ignore, replace, strict); you'll get the same TypeError. What am I doing wrong? Is this a bug in Python? -- http://mail.python.org/mailman/listinfo/python-list