mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
cave to those who like readable code
This commit is contained in:
parent
0268675193
commit
5944c36931
1 changed files with 15 additions and 1 deletions
|
@ -6164,7 +6164,21 @@ PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
|
||||||
kind = PyUnicode_KIND(unicode);
|
kind = PyUnicode_KIND(unicode);
|
||||||
data = PyUnicode_DATA(unicode);
|
data = PyUnicode_DATA(unicode);
|
||||||
len = PyUnicode_GET_LENGTH(unicode);
|
len = PyUnicode_GET_LENGTH(unicode);
|
||||||
expandsize = kind * 2 + 2;
|
expandsize = 0;
|
||||||
|
switch (kind) {
|
||||||
|
case PyUnicode_1BYTE_KIND:
|
||||||
|
expandsize = 4;
|
||||||
|
break;
|
||||||
|
case PyUnicode_2BYTE_KIND:
|
||||||
|
expandsize = 6;
|
||||||
|
break;
|
||||||
|
case PyUnicode_4BYTE_KIND:
|
||||||
|
expandsize = 10;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (len > PY_SSIZE_T_MAX / expandsize)
|
if (len > PY_SSIZE_T_MAX / expandsize)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue