[ python-Bugs-1459029 ] Doubled backslash in repr() method for unicode

SourceForge.net noreply at sourceforge.net
Mon Mar 27 08:38:46 CEST 2006


Bugs item #1459029, was opened at 2006-03-27 11:54
Message generated for change (Comment added) made by perky
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1459029&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: Python 2.4
Status: Open
Resolution: None
Priority: 7
Submitted By: Christoph Zwerschke (cito)
Assigned to: Hye-Shik Chang (perky)
Summary: Doubled backslash in repr() method for unicode

Initial Comment:
Here is an issue that caused Kid templates (used by
Turbogears) to malfunction in Python 2.4.3c1.

The problem shows up with the following code:

class s1:
    def __repr__(self):
        return '\\n'

class s2:
    def __repr__(self):
        return u'\\n'

print repr(s1()), repr(s2())

I get the following results:

Python 2.3.5: \n \n
Python 2.4.2: \n \n
Python 2.4.3c1: \n \\n 

In the output for Python 2.4.3c1, the backslash in the
representation of class2 appears doubled. This did not
happen in earlier Python versions and seems to be a bug.

My vague guess is that the issue may have crept in with
an attempted fix of Bug #1379994.

-- Christoph

----------------------------------------------------------------------

>Comment By: Hye-Shik Chang (perky)
Date: 2006-03-27 15:38

Message:
Logged In: YES 
user_id=55188

Looking the C code, unicode_repr is doing correct.
But the inconsistency came from PyObject_Repr.
This change made it which is intended:

------------------------------------------------------------------------
r16198 | effbot | 2000-07-09 02:43:32 +0900 (일, 09  7 2000)
| 6 lines


- changed __repr__ to use "unicode escape" encoding for unicode
  strings, instead of the default encoding.
  (see "minidom" thread for discussion, and also patch #100706)


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-03-27 15:28

Message:
Logged In: YES 
user_id=33168

Attached a patch for the test case to be added with fix.

----------------------------------------------------------------------

Comment By: Anthony Baxter (anthonybaxter)
Date: 2006-03-27 14:53

Message:
Logged In: YES 
user_id=29957

Confirmed - it's also broken in the trunk, and backing out
the patch for http://www.python.org/sf/1379994 (r41728)
fixes the problem. Perky, you checked this in - can you look
at this soon, please? I don't want to release 2.4.3 until
it's fixed, but I also want to get 2.4.3 out this week.

Thanks for the bug report!


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1459029&group_id=5470


More information about the Python-bugs-list mailing list