Commit afac54c5 authored by Victor Stinner's avatar Victor Stinner

Fix usage of PyUnicode_READY in unicodeobject.c

parent 3ee6e533
...@@ -7933,7 +7933,7 @@ PyUnicode_Count(PyObject *str, ...@@ -7933,7 +7933,7 @@ PyUnicode_Count(PyObject *str,
if (!str_obj || PyUnicode_READY(str_obj) == -1) if (!str_obj || PyUnicode_READY(str_obj) == -1)
return -1; return -1;
sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr); sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr);
if (!sub_obj || PyUnicode_READY(str_obj) == -1) { if (!sub_obj || PyUnicode_READY(sub_obj) == -1) {
Py_DECREF(str_obj); Py_DECREF(str_obj);
return -1; return -1;
} }
...@@ -8460,7 +8460,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq) ...@@ -8460,7 +8460,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
if (separator == NULL) { if (separator == NULL) {
/* fall back to a blank space separator */ /* fall back to a blank space separator */
sep = PyUnicode_FromOrdinal(' '); sep = PyUnicode_FromOrdinal(' ');
if (!sep || PyUnicode_READY(sep) == -1) if (!sep)
goto onError; goto onError;
} }
else { else {
...@@ -9190,10 +9190,6 @@ convert_uc(PyObject *obj, void *addr) ...@@ -9190,10 +9190,6 @@ convert_uc(PyObject *obj, void *addr)
Py_DECREF(uniobj); Py_DECREF(uniobj);
return 0; return 0;
} }
if (PyUnicode_READY(uniobj)) {
Py_DECREF(uniobj);
return 0;
}
*fillcharloc = PyUnicode_READ_CHAR(uniobj, 0); *fillcharloc = PyUnicode_READ_CHAR(uniobj, 0);
Py_DECREF(uniobj); Py_DECREF(uniobj);
return 1; return 1;
...@@ -9212,10 +9208,10 @@ unicode_center(PyUnicodeObject *self, PyObject *args) ...@@ -9212,10 +9208,10 @@ unicode_center(PyUnicodeObject *self, PyObject *args)
Py_ssize_t width; Py_ssize_t width;
Py_UCS4 fillchar = ' '; Py_UCS4 fillchar = ' ';
if (PyUnicode_READY(self) == -1) if (!PyArg_ParseTuple(args, "n|O&:center", &width, convert_uc, &fillchar))
return NULL; return NULL;
if (!PyArg_ParseTuple(args, "n|O&:center", &width, convert_uc, &fillchar)) if (PyUnicode_READY(self) == -1)
return NULL; return NULL;
if (_PyUnicode_LENGTH(self) >= width && PyUnicode_CheckExact(self)) { if (_PyUnicode_LENGTH(self) >= width && PyUnicode_CheckExact(self)) {
...@@ -9437,7 +9433,7 @@ PyUnicode_Contains(PyObject *container, PyObject *element) ...@@ -9437,7 +9433,7 @@ PyUnicode_Contains(PyObject *container, PyObject *element)
return -1; return -1;
str = PyUnicode_FromObject(container); str = PyUnicode_FromObject(container);
if (!str || PyUnicode_READY(container) == -1) { if (!str || PyUnicode_READY(str) == -1) {
Py_DECREF(sub); Py_DECREF(sub);
return -1; return -1;
} }
...@@ -9515,9 +9511,6 @@ PyUnicode_Concat(PyObject *left, PyObject *right) ...@@ -9515,9 +9511,6 @@ PyUnicode_Concat(PyObject *left, PyObject *right)
return v; return v;
} }
if (PyUnicode_READY(u) == -1 || PyUnicode_READY(v) == -1)
goto onError;
maxchar = PyUnicode_MAX_CHAR_VALUE(u); maxchar = PyUnicode_MAX_CHAR_VALUE(u);
maxchar = Py_MAX(maxchar, PyUnicode_MAX_CHAR_VALUE(v)); maxchar = Py_MAX(maxchar, PyUnicode_MAX_CHAR_VALUE(v));
...@@ -10662,15 +10655,15 @@ PyUnicode_Replace(PyObject *obj, ...@@ -10662,15 +10655,15 @@ PyUnicode_Replace(PyObject *obj,
PyObject *result; PyObject *result;
self = PyUnicode_FromObject(obj); self = PyUnicode_FromObject(obj);
if (self == NULL || PyUnicode_READY(obj) == -1) if (self == NULL || PyUnicode_READY(self) == -1)
return NULL; return NULL;
str1 = PyUnicode_FromObject(subobj); str1 = PyUnicode_FromObject(subobj);
if (str1 == NULL || PyUnicode_READY(obj) == -1) { if (str1 == NULL || PyUnicode_READY(str1) == -1) {
Py_DECREF(self); Py_DECREF(self);
return NULL; return NULL;
} }
str2 = PyUnicode_FromObject(replobj); str2 = PyUnicode_FromObject(replobj);
if (str2 == NULL || PyUnicode_READY(obj)) { if (str2 == NULL || PyUnicode_READY(str2)) {
Py_DECREF(self); Py_DECREF(self);
Py_DECREF(str1); Py_DECREF(str1);
return NULL; return NULL;
...@@ -10705,7 +10698,7 @@ unicode_replace(PyObject *self, PyObject *args) ...@@ -10705,7 +10698,7 @@ unicode_replace(PyObject *self, PyObject *args)
if (str1 == NULL || PyUnicode_READY(str1) == -1) if (str1 == NULL || PyUnicode_READY(str1) == -1)
return NULL; return NULL;
str2 = PyUnicode_FromObject(str2); str2 = PyUnicode_FromObject(str2);
if (str2 == NULL || PyUnicode_READY(str1) == -1) { if (str2 == NULL || PyUnicode_READY(str2) == -1) {
Py_DECREF(str1); Py_DECREF(str1);
return NULL; return NULL;
} }
...@@ -10958,10 +10951,10 @@ unicode_rjust(PyUnicodeObject *self, PyObject *args) ...@@ -10958,10 +10951,10 @@ unicode_rjust(PyUnicodeObject *self, PyObject *args)
Py_ssize_t width; Py_ssize_t width;
Py_UCS4 fillchar = ' '; Py_UCS4 fillchar = ' ';
if (PyUnicode_READY(self) == -1) if (!PyArg_ParseTuple(args, "n|O&:rjust", &width, convert_uc, &fillchar))
return NULL; return NULL;
if (!PyArg_ParseTuple(args, "n|O&:rjust", &width, convert_uc, &fillchar)) if (PyUnicode_READY(self) == -1)
return NULL; return NULL;
if (_PyUnicode_LENGTH(self) >= width && PyUnicode_CheckExact(self)) { if (_PyUnicode_LENGTH(self) >= width && PyUnicode_CheckExact(self)) {
...@@ -11032,7 +11025,7 @@ PyUnicode_Partition(PyObject *str_in, PyObject *sep_in) ...@@ -11032,7 +11025,7 @@ PyUnicode_Partition(PyObject *str_in, PyObject *sep_in)
Py_ssize_t len1, len2; Py_ssize_t len1, len2;
str_obj = PyUnicode_FromObject(str_in); str_obj = PyUnicode_FromObject(str_in);
if (!str_obj || PyUnicode_READY(str_in) == -1) if (!str_obj || PyUnicode_READY(str_obj) == -1)
return NULL; return NULL;
sep_obj = PyUnicode_FromObject(sep_in); sep_obj = PyUnicode_FromObject(sep_in);
if (!sep_obj || PyUnicode_READY(sep_obj) == -1) { if (!sep_obj || PyUnicode_READY(sep_obj) == -1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment