M
Mike Brown
This works as expected (this is on an ASCII terminal):
u'asdf\ufffd'
This does not work as I expect it to:
.... def __str__(self):
.... return 'asdf\xff'
....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?
u'asdf\ufffd'
This does not work as I expect it to:
.... def __str__(self):
.... return 'asdf\xff'
....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?