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
1a691813
Commit
1a691813
authored
Nov 20, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
charmap_encoding_error() uses the new Unicode API
parent
1ec4a7c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
Objects/unicodeobject.c
Objects/unicodeobject.c
+13
-3
No files found.
Objects/unicodeobject.c
View file @
1a691813
...
...
@@ -8087,7 +8087,9 @@ charmap_encoding_error(
PyObject
*
repunicode
=
NULL
;
/* initialize to prevent gcc warning */
Py_ssize_t
size
,
repsize
;
Py_ssize_t
newpos
;
Py_UNICODE
*
uni2
;
enum
PyUnicode_Kind
kind
;
void
*
data
;
Py_ssize_t
index
;
/* startpos for collecting unencodable chars */
Py_ssize_t
collstartpos
=
*
inpos
;
Py_ssize_t
collendpos
=
*
inpos
+
1
;
...
...
@@ -8201,10 +8203,18 @@ charmap_encoding_error(
break
;
}
/* generate replacement */
if
(
PyUnicode_READY
(
repunicode
)
<
0
)
{
Py_DECREF
(
repunicode
);
return
-
1
;
}
repsize
=
PyUnicode_GET_SIZE
(
repunicode
);
for
(
uni2
=
PyUnicode_AS_UNICODE
(
repunicode
);
repsize
-->
0
;
++
uni2
)
{
x
=
charmapencode_output
(
*
uni2
,
mapping
,
res
,
respos
);
data
=
PyUnicode_DATA
(
repunicode
);
kind
=
PyUnicode_KIND
(
repunicode
);
for
(
index
=
0
;
index
<
repsize
;
index
++
)
{
Py_UCS4
repch
=
PyUnicode_READ
(
kind
,
data
,
index
);
x
=
charmapencode_output
(
repch
,
mapping
,
res
,
respos
);
if
(
x
==
enc_EXCEPTION
)
{
Py_DECREF
(
repunicode
);
return
-
1
;
}
else
if
(
x
==
enc_FAILED
)
{
...
...
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