This works as expected (this is on an ASCII terminal):
[color=blue][color=green][color=darkred]
>>> unicode('asdf\x ff', errors='replace ')[/color][/color][/color]
u'asdf\ufffd'
This does not work as I expect it to:
[color=blue][color=green][color=darkred]
>>> class C:[/color][/color][/color]
.... def __str__(self):
.... return 'asdf\xff'
....[color=blue][color=green][color=darkred]
>>> o = C()
>>> unicode(o, errors='replace ')[/color][/color][/color]
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(sel f), 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?
[color=blue][color=green][color=darkred]
>>> unicode('asdf\x ff', errors='replace ')[/color][/color][/color]
u'asdf\ufffd'
This does not work as I expect it to:
[color=blue][color=green][color=darkred]
>>> class C:[/color][/color][/color]
.... def __str__(self):
.... return 'asdf\xff'
....[color=blue][color=green][color=darkred]
>>> o = C()
>>> unicode(o, errors='replace ')[/color][/color][/color]
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(sel f), 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?
Comment