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
0617b6e1
Commit
0617b6e1
authored
Oct 05, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unicode_fromascii() checks that the input is ASCII in debug mode
parent
a336de7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
Objects/unicodeobject.c
Objects/unicodeobject.c
+11
-3
No files found.
Objects/unicodeobject.c
View file @
0617b6e1
...
...
@@ -1537,12 +1537,20 @@ PyUnicode_FromString(const char *u)
}
static
PyObject
*
unicode_fromascii
(
const
unsigned
char
*
u
,
Py_ssize_t
size
)
unicode_fromascii
(
const
unsigned
char
*
s
,
Py_ssize_t
size
)
{
PyObject
*
res
=
PyUnicode_New
(
size
,
127
);
PyObject
*
res
;
#ifdef Py_DEBUG
const
unsigned
char
*
p
;
const
unsigned
char
*
end
=
s
+
size
;
for
(
p
=
s
;
p
<
end
;
p
++
)
{
assert
(
*
p
<
128
);
}
#endif
res
=
PyUnicode_New
(
size
,
127
);
if
(
!
res
)
return
NULL
;
memcpy
(
PyUnicode_1BYTE_DATA
(
res
),
u
,
size
);
memcpy
(
PyUnicode_1BYTE_DATA
(
res
),
s
,
size
);
return
res
;
}
...
...
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