Serhiy Storchaka added the comment:

In Python 3 ascii() uses the backslashreplace error handler.

>>> class T:
...     def __repr__(self):
...         return '\u20ac\udcff'
... 
>>> print(ascii(T()))
\u20ac\udcff

I think using the backslashreplace error handler in repr() in Python 2.7 is 
good solution. Here is a patch.

----------
keywords: +patch
nosy: +serhiy.storchaka
stage: test needed -> patch review
Added file: http://bugs.python.org/file31439/unicode_repr.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5876>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to