This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: "unicode_escape" and "raw_unicode_escape" encoding is broken
Type: Stage:
Components: Unicode Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: hyeshik.chang Nosy List: anthonybaxter, georg.brandl, hyeshik.chang, lemburg, markmcmahon
Priority: normal Keywords:

Created on 2005-12-14 00:47 by markmcmahon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unicodeescape.diff hyeshik.chang, 2005-12-14 01:41 patch to unicodeobject.c
Messages (6)
msg27064 - (view) Author: Mark Mc Mahon (markmcmahon) Date: 2005-12-14 00:47
In Python 2.4.2 and Python 2.4.1 (Windows XP)

>>> "\t\\t".encode("string_escape")
'\\t\\\\t'

>>> "\t\\t".encode("unicode_escape")
'\\t\\t'
>>> "\t\\t".encode("raw_unicode_escape")
'\t\\t'
>>> u"\t\\t".encode("unicode_escape")
'\\t\\t'
>>> u"\t\\t".encode("raw_unicode_escape")
'\t\\t'

I would have expected all to produce the same result.

Also round-tripping with the encoding doesn't seem to work:
>>> "\t\\t".encode('string_escape').decode('string_escape')
'\t\\t'
>>>
u"\t\\t".encode('unicode_escape').decode('unicode_escape')
u'\t\t'

Thanks
   Mark
msg27065 - (view) Author: Hyeshik Chang (hyeshik.chang) * (Python committer) Date: 2005-12-14 01:41
Logged In: YES 
user_id=55188

Attached a patch. It looks like a simple typo. :)
msg27066 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-12-15 21:39
Logged In: YES 
user_id=1188172

Patch looks good.
msg27067 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2005-12-16 15:01
Logged In: YES 
user_id=38388

Please add a test case and check in the patch.
Thanks.
msg27068 - (view) Author: Hyeshik Chang (hyeshik.chang) * (Python committer) Date: 2005-12-17 04:39
Logged In: YES 
user_id=55188

Committed as r41728. Thank you!
msg27069 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2006-03-28 07:38
Logged In: YES 
user_id=29957

This caused other issues (#1459029) and was reverted from
the 2.4 branch. Fix is still in 2.5. 
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42691
2005-12-14 00:47:26markmcmahoncreate