mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
unicode_fromascii() doesn't check string content twice in debug mode
_PyUnicode_CheckConsistency() also checks string content.
This commit is contained in:
parent
a1d12bb119
commit
e6b2d4407a
1 changed files with 3 additions and 6 deletions
|
@ -1768,15 +1768,12 @@ static PyObject*
|
||||||
unicode_fromascii(const unsigned char* s, Py_ssize_t size)
|
unicode_fromascii(const unsigned char* s, Py_ssize_t size)
|
||||||
{
|
{
|
||||||
PyObject *unicode;
|
PyObject *unicode;
|
||||||
|
if (size == 1) {
|
||||||
#ifdef Py_DEBUG
|
#ifdef Py_DEBUG
|
||||||
const unsigned char *p;
|
assert(s[0] < 128);
|
||||||
const unsigned char *end = s + size;
|
|
||||||
for (p=s; p < end; p++) {
|
|
||||||
assert(*p < 128);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (size == 1)
|
|
||||||
return get_latin1_char(s[0]);
|
return get_latin1_char(s[0]);
|
||||||
|
}
|
||||||
unicode = PyUnicode_New(size, 127);
|
unicode = PyUnicode_New(size, 127);
|
||||||
if (!unicode)
|
if (!unicode)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue