[Python-Dev] Inconsistency in 2.4.3 for repr() returning unicode (original) (raw)
Hye-Shik Chang hyeshik at gmail.com
Mon Mar 27 09:40:30 CEST 2006
- Previous message: [Python-Dev] refleaks in 2.4
- Next message: [Python-Dev] Inconsistency in 2.4.3 for __repr__() returning unicode
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
We got an inconsistency for repr() returning unicode as reported in http://python.org/sf/1459029 :
class s1: def repr(self): return '\n'
class s2: def repr(self): return u'\n'
print repr(s1()), repr(s2())
Until 2.4.2: \n \n 2.4.3: \n \n
\n looks bit weird but it's correct. As once discussed[1] in python-dev before, if repr returns unicode object, PyObject_Repr encodes it via unicode-escape codec. So, non-latin character also could be in repr neutrally.
But our unicode-escape had a bug since when it is introduced. The bug was that it doesn't escape backslashes. Therefore, backslashes wasn't escaped in repr while it sholud be escaped because we used the unicode-escape codec.
So, fixing the bug made a behavior inconsistency. How do we resolve the problem?
Hye-Shik
[1] http://mail.python.org/pipermail/python-dev/2000-July/005353.html
- Previous message: [Python-Dev] refleaks in 2.4
- Next message: [Python-Dev] Inconsistency in 2.4.3 for __repr__() returning unicode
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]