mirror of
https://github.com/python/cpython.git
synced 2025-07-14 23:05:17 +00:00
bpo-31393: Fix the use of PyUnicode_READY(). (#3451)
This commit is contained in:
parent
70c2dd306f
commit
e3b2b4b8d9
5 changed files with 30 additions and 14 deletions
|
@ -4185,10 +4185,13 @@ PyUnicode_ReadChar(PyObject *unicode, Py_ssize_t index)
|
|||
void *data;
|
||||
int kind;
|
||||
|
||||
if (!PyUnicode_Check(unicode) || PyUnicode_READY(unicode) == -1) {
|
||||
if (!PyUnicode_Check(unicode)) {
|
||||
PyErr_BadArgument();
|
||||
return (Py_UCS4)-1;
|
||||
}
|
||||
if (PyUnicode_READY(unicode) == -1) {
|
||||
return (Py_UCS4)-1;
|
||||
}
|
||||
if (index < 0 || index >= PyUnicode_GET_LENGTH(unicode)) {
|
||||
PyErr_SetString(PyExc_IndexError, "string index out of range");
|
||||
return (Py_UCS4)-1;
|
||||
|
@ -11668,10 +11671,13 @@ unicode_getitem(PyObject *self, Py_ssize_t index)
|
|||
enum PyUnicode_Kind kind;
|
||||
Py_UCS4 ch;
|
||||
|
||||
if (!PyUnicode_Check(self) || PyUnicode_READY(self) == -1) {
|
||||
if (!PyUnicode_Check(self)) {
|
||||
PyErr_BadArgument();
|
||||
return NULL;
|
||||
}
|
||||
if (PyUnicode_READY(self) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
if (index < 0 || index >= PyUnicode_GET_LENGTH(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "string index out of range");
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue