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
a98b28c1
Commit
a98b28c1
authored
Nov 10, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid PyUnicode_AS_UNICODE in the UTF-8 encoder
parent
3326cb6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
Objects/unicodeobject.c
Objects/unicodeobject.c
+11
-4
No files found.
Objects/unicodeobject.c
View file @
a98b28c1
...
...
@@ -4820,11 +4820,18 @@ _PyUnicode_AsUTF8String(PyObject *unicode, const char *errors)
for
(
k
=
repsize
;
k
>
0
;
k
--
)
*
p
++
=
*
prep
++
;
}
else
/* rep is unicode */
{
const
Py_UNICODE
*
prep
=
PyUnicode_AS_UNICODE
(
rep
);
Py_UNICODE
c
;
enum
PyUnicode_Kind
repkind
;
void
*
repdata
;
if
(
PyUnicode_READY
(
rep
)
<
0
)
{
Py_DECREF
(
rep
);
goto
error
;
}
repkind
=
PyUnicode_KIND
(
rep
);
repdata
=
PyUnicode_DATA
(
rep
);
for
(
k
=
0
;
k
<
repsize
;
k
++
)
{
c
=
prep
[
k
]
;
Py_UCS4
c
=
PyUnicode_READ
(
repkind
,
repdata
,
k
)
;
if
(
0x80
<=
c
)
{
raise_encode_exception
(
&
exc
,
"utf-8"
,
unicode
,
...
...
@@ -4832,7 +4839,7 @@ _PyUnicode_AsUTF8String(PyObject *unicode, const char *errors)
"surrogates not allowed"
);
goto
error
;
}
*
p
++
=
(
char
)
prep
[
k
]
;
*
p
++
=
(
char
)
c
;
}
}
Py_DECREF
(
rep
);
...
...
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