mirror of https://github.com/python/cpython
Fix misuse of PyUnicode_GET_SIZE, use PyUnicode_GET_LENGTH instead
This commit is contained in:
parent
ed2682be2f
commit
c4f281eba3
|
@ -2719,7 +2719,7 @@ PyCurses_ConvertToWchar_t(PyObject *obj,
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"expect bytes or str of length 1, or int, "
|
"expect bytes or str of length 1, or int, "
|
||||||
"got a str of length %zi",
|
"got a str of length %zi",
|
||||||
PyUnicode_GET_SIZE(obj));
|
PyUnicode_GET_LENGTH(obj));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*wch = buffer[0];
|
*wch = buffer[0];
|
||||||
|
|
|
@ -343,7 +343,7 @@ stringio_iternext(stringio *self)
|
||||||
if (line == NULL)
|
if (line == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (PyUnicode_GET_SIZE(line) == 0) {
|
if (PyUnicode_GET_LENGTH(line) == 0) {
|
||||||
/* Reached EOF */
|
/* Reached EOF */
|
||||||
Py_DECREF(line);
|
Py_DECREF(line);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -837,7 +837,7 @@ _parse_constant(PyScannerObject *s, char *constant, Py_ssize_t idx, Py_ssize_t *
|
||||||
|
|
||||||
/* rval = parse_constant(constant) */
|
/* rval = parse_constant(constant) */
|
||||||
rval = PyObject_CallFunctionObjArgs(s->parse_constant, cstr, NULL);
|
rval = PyObject_CallFunctionObjArgs(s->parse_constant, cstr, NULL);
|
||||||
idx += PyUnicode_GET_SIZE(cstr);
|
idx += PyUnicode_GET_LENGTH(cstr);
|
||||||
Py_DECREF(cstr);
|
Py_DECREF(cstr);
|
||||||
*next_idx_ptr = idx;
|
*next_idx_ptr = idx;
|
||||||
return rval;
|
return rval;
|
||||||
|
|
|
@ -90,18 +90,16 @@ syslog_get_argv(void)
|
||||||
if (!PyUnicode_Check(scriptobj)) {
|
if (!PyUnicode_Check(scriptobj)) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
scriptlen = PyUnicode_GET_SIZE(scriptobj);
|
scriptlen = PyUnicode_GET_LENGTH(scriptobj);
|
||||||
if (scriptlen == 0) {
|
if (scriptlen == 0) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
slash = PyUnicode_FindChar(scriptobj, SEP,
|
slash = PyUnicode_FindChar(scriptobj, SEP, 0, scriptlen, -1);
|
||||||
0, PyUnicode_GET_LENGTH(scriptobj), -1);
|
|
||||||
if (slash == -2)
|
if (slash == -2)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (slash != -1) {
|
if (slash != -1) {
|
||||||
return PyUnicode_Substring(scriptobj, slash,
|
return PyUnicode_Substring(scriptobj, slash, scriptlen);
|
||||||
PyUnicode_GET_LENGTH(scriptobj));
|
|
||||||
} else {
|
} else {
|
||||||
Py_INCREF(scriptobj);
|
Py_INCREF(scriptobj);
|
||||||
return(scriptobj);
|
return(scriptobj);
|
||||||
|
|
|
@ -12181,7 +12181,7 @@ unicode_maketrans(PyUnicodeObject *null, PyObject *args)
|
||||||
if (z != NULL) {
|
if (z != NULL) {
|
||||||
z_kind = PyUnicode_KIND(z);
|
z_kind = PyUnicode_KIND(z);
|
||||||
z_data = PyUnicode_DATA(z);
|
z_data = PyUnicode_DATA(z);
|
||||||
for (i = 0; i < PyUnicode_GET_SIZE(z); i++) {
|
for (i = 0; i < PyUnicode_GET_LENGTH(z); i++) {
|
||||||
key = PyLong_FromLong(PyUnicode_READ(z_kind, z_data, i));
|
key = PyLong_FromLong(PyUnicode_READ(z_kind, z_data, i));
|
||||||
if (!key)
|
if (!key)
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -12206,7 +12206,7 @@ unicode_maketrans(PyUnicodeObject *null, PyObject *args)
|
||||||
if (PyUnicode_Check(key)) {
|
if (PyUnicode_Check(key)) {
|
||||||
/* convert string keys to integer keys */
|
/* convert string keys to integer keys */
|
||||||
PyObject *newkey;
|
PyObject *newkey;
|
||||||
if (PyUnicode_GET_SIZE(key) != 1) {
|
if (PyUnicode_GET_LENGTH(key) != 1) {
|
||||||
PyErr_SetString(PyExc_ValueError, "string keys in translate "
|
PyErr_SetString(PyExc_ValueError, "string keys in translate "
|
||||||
"table must be of length 1");
|
"table must be of length 1");
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -13694,7 +13694,7 @@ unicodeiter_len(unicodeiterobject *it)
|
||||||
{
|
{
|
||||||
Py_ssize_t len = 0;
|
Py_ssize_t len = 0;
|
||||||
if (it->it_seq)
|
if (it->it_seq)
|
||||||
len = PyUnicode_GET_SIZE(it->it_seq) - it->it_index;
|
len = PyUnicode_GET_LENGTH(it->it_seq) - it->it_index;
|
||||||
return PyLong_FromSsize_t(len);
|
return PyLong_FromSsize_t(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -693,7 +693,7 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format)
|
||||||
Py_ssize_t rpad;
|
Py_ssize_t rpad;
|
||||||
Py_ssize_t total;
|
Py_ssize_t total;
|
||||||
Py_ssize_t pos;
|
Py_ssize_t pos;
|
||||||
Py_ssize_t len = PyUnicode_GET_SIZE(value);
|
Py_ssize_t len = PyUnicode_GET_LENGTH(value);
|
||||||
PyObject *result = NULL;
|
PyObject *result = NULL;
|
||||||
int maxchar = 127;
|
int maxchar = 127;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue