fix compiler warning by implementing this more cleverly

This commit is contained in:
Benjamin Peterson 2011-11-22 15:29:32 -05:00
parent f683700121
commit 0268675193
1 changed files with 1 additions and 6 deletions

View File

@ -6164,12 +6164,7 @@ PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
kind = PyUnicode_KIND(unicode);
data = PyUnicode_DATA(unicode);
len = PyUnicode_GET_LENGTH(unicode);
switch(kind) {
case PyUnicode_1BYTE_KIND: expandsize = 4; break;
case PyUnicode_2BYTE_KIND: expandsize = 6; break;
case PyUnicode_4BYTE_KIND: expandsize = 10; break;
}
expandsize = kind * 2 + 2;
if (len > PY_SSIZE_T_MAX / expandsize)
return PyErr_NoMemory();