STINNER Victor <victor.stin...@haypocalc.com> added the comment: > Debian SID. No, it wasn't.
Oh ok, gotcha: repr() always returns a str string. If obj.__repr__() returns a Unicode string, the string is encoded to the default encoding. By default, the default encoding is ASCII. $ ./python -S Python 2.7.2+ (2.7:85a12278de69, Sep 2 2011, 00:21:57) [GCC 4.6.0 20110603 (Red Hat 4.6.0-10)] on linux2 >>> import sys >>> sys.setdefaultencoding('ISO-8859-1') >>> class A(object): ... def __repr__(self): return u'\xe9' ... >>> repr(A()) '\xe9' Don't do that at home! Change the default encoding is not a good idea. I don't think that repr(obj) can be changed to return Unicode if obj.__repr__() returns Unicode. It is too late to change such thing in Python 2. ---------- _______________________________________ 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