Title: string-escape codec incorrect
Type: behaviour Severity: normal
Components: Core Versions: 2.5.1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: gz, pjenvey
Priority: Keywords: patch

Created on 2009-11-12.16:11:42 by gz, last changed 2010-04-06.23:49:50 by gz.

File name Uploaded Description Edit Remove
jython_string_escape_codec.patch gz, 2009-11-12.16:11:41 Fix, diff against svn trunk
msg5307 (view) Author: Martin (gz) Date: 2009-11-12.16:11:41
The 'string-escape' codec (and its unicode cousin) do not escape the 
escape character, thus fail to roundtrip.

Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_16
Type "help", "copyright", "credits" or "license" for more information.
>>> "\\x00".encode("string-escape")
>>> _.decode("string-escape")

One of the issues reported on jython-dev last week pertaining to 
running bazaar on jython.
msg5635 (view) Author: Philip Jenvey (pjenvey) Date: 2010-04-05.01:49:20
fixed in r7001

IIRC I tried your patch a long time ago and it broke other things. I opted to go with CPython's slightly less efficient solution. Thanks
msg5636 (view) Author: Martin (gz) Date: 2010-04-05.06:15:30
Might have been nice to mention what it broke at the time, I could perhaps have posted a follow up.

I have trouble believing that the current behaviour of not escaping the escape character is ever right, even if some other callers might need to be adjusted.

Your commit fails to fix _codecs.unicode_escape_encode as it only touches _codecs.escape_encode - if you want a change in that module rather than PyString they both need doing.
msg5639 (view) Author: Philip Jenvey (pjenvey) Date: 2010-04-06.02:03:01
My mistake, your original patch was fine. I must have been thinking of something else. Applied in r7002 with an additional test for unicode-escape.

Thanks for the patch and the followup
msg5641 (view) Author: Martin (gz) Date: 2010-04-06.23:49:49
Ah, great, thanks for double checking that.
Date User Action Args
2010-04-06 23:49:50gzsetmessages: + msg5641
2010-04-06 02:03:02pjenveysetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg5639
2010-04-05 06:37:58pjenveysetstatus: closed -> open
resolution: fixed -> accepted
2010-04-05 06:15:31gzsetmessages: + msg5636
2010-04-05 01:49:21pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg5635
2010-04-04 18:29:49pjenveysetassignee: pjenvey
nosy: + pjenvey
2009-11-12 16:11:42gzcreate