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
034b0acd
Commit
034b0acd
authored
Apr 05, 2010
by
Philip Jenvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix escape_encode to return the correct consumed size
parent
dd194ab3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
Lib/test/test_codecs.py
Lib/test/test_codecs.py
+3
-0
Modules/_codecsmodule.c
Modules/_codecsmodule.c
+5
-4
No files found.
Lib/test/test_codecs.py
View file @
034b0acd
...
...
@@ -835,6 +835,9 @@ class UnicodeInternalTest(unittest.TestCase):
self
.
assertEquals
(
encoder
(
u"a"
)[
1
],
1
)
self
.
assertEquals
(
encoder
(
u"
\
xe9
\
u0142
"
)[
1
],
2
)
encoder
=
codecs
.
getencoder
(
"string-escape"
)
self
.
assertEquals
(
encoder
(
r'\x00'
)[
1
],
4
)
# From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
nameprep_tests
=
[
# 3.1 Map to nothing.
...
...
Modules/_codecsmodule.c
View file @
034b0acd
...
...
@@ -179,12 +179,13 @@ escape_encode(PyObject *self,
PyObject
*
str
;
const
char
*
errors
=
NULL
;
char
*
buf
;
Py_ssize_t
len
;
Py_ssize_t
consumed
,
len
;
if
(
!
PyArg_ParseTuple
(
args
,
"
O!
|z:escape_encode"
,
&
PyString_Type
,
&
str
,
&
errors
))
if
(
!
PyArg_ParseTuple
(
args
,
"
S
|z:escape_encode"
,
&
str
,
&
errors
))
return
NULL
;
consumed
=
PyString_GET_SIZE
(
str
);
str
=
PyString_Repr
(
str
,
0
);
if
(
!
str
)
return
NULL
;
...
...
@@ -196,7 +197,7 @@ escape_encode(PyObject *self,
if
(
_PyString_Resize
(
&
str
,
len
-
2
)
<
0
)
return
NULL
;
return
codec_tuple
(
str
,
PyString_Size
(
str
)
);
return
codec_tuple
(
str
,
consumed
);
}
#ifdef Py_USING_UNICODE
...
...
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