Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
835b243c
Commit
835b243c
authored
Dec 17, 2005
by
Hye-Shik Chang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1379994: Fix *unicode_escape codecs to encode r'\' as r'\\'
just like string codecs.
parent
e3547fd2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
13 deletions
+20
-13
Lib/test/test_unicode.py
Lib/test/test_unicode.py
+14
-10
Misc/NEWS
Misc/NEWS
+3
-0
Objects/unicodeobject.c
Objects/unicodeobject.c
+3
-3
No files found.
Lib/test/test_unicode.py
View file @
835b243c
...
@@ -615,20 +615,24 @@ class UnicodeTest(
...
@@ -615,20 +615,24 @@ class UnicodeTest(
self.assertEqual(u'
hello
'.encode('
latin
-
1
'), '
hello
')
self.assertEqual(u'
hello
'.encode('
latin
-
1
'), '
hello
')
# Roundtrip safety for BMP (just the first 1024 chars)
# Roundtrip safety for BMP (just the first 1024 chars)
u = u''.join(map(unichr, xrange(1024)))
for c in xrange(1024):
for encoding in ('
utf
-
7
', '
utf
-
8
', '
utf
-
16
', '
utf
-
16
-
le
', '
utf
-
16
-
be
',
u = unichr(c)
'
raw_unicode_escape
', '
unicode_escape
', '
unicode_internal
'):
for encoding in ('
utf
-
7
', '
utf
-
8
', '
utf
-
16
', '
utf
-
16
-
le
',
self.assertEqual(unicode(u.encode(encoding),encoding), u)
'
utf
-
16
-
be
', '
raw_unicode_escape
',
'
unicode_escape
', '
unicode_internal
'):
self.assertEqual(unicode(u.encode(encoding),encoding), u)
# Roundtrip safety for BMP (just the first 256 chars)
# Roundtrip safety for BMP (just the first 256 chars)
u = u''.join(map(unichr, xrange(256)))
for c in xrange(256):
for encoding in ('
latin
-
1
',):
u = unichr(c)
self.assertEqual(unicode(u.encode(encoding),encoding), u)
for encoding in ('
latin
-
1
',):
self.assertEqual(unicode(u.encode(encoding),encoding), u)
# Roundtrip safety for BMP (just the first 128 chars)
# Roundtrip safety for BMP (just the first 128 chars)
u = u''.join(map(unichr, xrange(128)))
for c in xrange(128):
for encoding in ('
ascii
',):
u = unichr(c)
self.assertEqual(unicode(u.encode(encoding),encoding), u)
for encoding in ('
ascii
',):
self.assertEqual(unicode(u.encode(encoding),encoding), u)
# Roundtrip safety for non-BMP (just a few chars)
# Roundtrip safety for non-BMP (just a few chars)
u = u'
\
U00010001
\
U00020002
\
U00030003
\
U00040004
\
U00050005
'
u = u'
\
U00010001
\
U00020002
\
U00030003
\
U00040004
\
U00050005
'
...
...
Misc/NEWS
View file @
835b243c
...
@@ -12,6 +12,9 @@ What's New in Python 2.5 alpha 1?
...
@@ -12,6 +12,9 @@ What's New in Python 2.5 alpha 1?
Core and builtins
Core and builtins
-----------------
-----------------
- Bug #1379994: Builtin unicode_escape and raw_unicode_escape codec
now encodes backslash correctly.
- Patch #1350409: Work around signal handling bug in Visual Studio 2005.
- Patch #1350409: Work around signal handling bug in Visual Studio 2005.
- Bug #1281408: Py_BuildValue now works correct even with unsigned longs
- Bug #1281408: Py_BuildValue now works correct even with unsigned longs
...
...
Objects/unicodeobject.c
View file @
835b243c
...
@@ -1989,9 +1989,9 @@ PyObject *unicodeescape_string(const Py_UNICODE *s,
...
@@ -1989,9 +1989,9 @@ PyObject *unicodeescape_string(const Py_UNICODE *s,
while
(
size
--
>
0
)
{
while
(
size
--
>
0
)
{
Py_UNICODE
ch
=
*
s
++
;
Py_UNICODE
ch
=
*
s
++
;
/* Escape quotes */
/* Escape quotes
and backslashes
*/
if
(
quotes
&&
if
(
(
quotes
&&
(
ch
==
(
Py_UNICODE
)
PyString_AS_STRING
(
repr
)[
1
]
||
ch
==
'\\'
)
)
{
ch
==
(
Py_UNICODE
)
PyString_AS_STRING
(
repr
)[
1
])
||
ch
==
'\\'
)
{
*
p
++
=
'\\'
;
*
p
++
=
'\\'
;
*
p
++
=
(
char
)
ch
;
*
p
++
=
(
char
)
ch
;
continue
;
continue
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment