bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. (GH-19472)

This commit is contained in:
Serhiy Storchaka 2020-04-12 14:58:27 +03:00 committed by GitHub
parent 3e0dd3730b
commit 8f87eefe7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 38 additions and 37 deletions

View file

@ -1598,7 +1598,7 @@ bytes_subscript(PyBytesObject* self, PyObject* item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength, i;
size_t cur;
char* source_buf;
const char* source_buf;
char* result_buf;
PyObject* result;
@ -1863,7 +1863,7 @@ Py_LOCAL_INLINE(PyObject *)
do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj)
{
Py_buffer vsep;
char *s = PyBytes_AS_STRING(self);
const char *s = PyBytes_AS_STRING(self);
Py_ssize_t len = PyBytes_GET_SIZE(self);
char *sep;
Py_ssize_t seplen;
@ -1903,7 +1903,7 @@ do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj)
Py_LOCAL_INLINE(PyObject *)
do_strip(PyBytesObject *self, int striptype)
{
char *s = PyBytes_AS_STRING(self);
const char *s = PyBytes_AS_STRING(self);
Py_ssize_t len = PyBytes_GET_SIZE(self), i, j;
i = 0;
@ -2020,7 +2020,8 @@ bytes_translate_impl(PyBytesObject *self, PyObject *table,
PyObject *deletechars)
/*[clinic end generated code: output=43be3437f1956211 input=0ecdf159f654233c]*/
{
char *input, *output;
const char *input;
char *output;
Py_buffer table_view = {NULL, NULL};
Py_buffer del_table_view = {NULL, NULL};
const char *table_chars;
@ -2371,7 +2372,7 @@ static PyObject *
bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep)
/*[clinic end generated code: output=1f134da504064139 input=f1238d3455990218]*/
{
char* argbuf = PyBytes_AS_STRING(self);
const char *argbuf = PyBytes_AS_STRING(self);
Py_ssize_t arglen = PyBytes_GET_SIZE(self);
return _Py_strhex_with_sep(argbuf, arglen, sep, bytes_per_sep);
}
@ -3188,7 +3189,7 @@ _PyBytesWriter_AsString(_PyBytesWriter *writer)
Py_LOCAL_INLINE(Py_ssize_t)
_PyBytesWriter_GetSize(_PyBytesWriter *writer, char *str)
{
char *start = _PyBytesWriter_AsString(writer);
const char *start = _PyBytesWriter_AsString(writer);
assert(str != NULL);
assert(str >= start);
assert(str - start <= writer->allocated);
@ -3199,7 +3200,7 @@ _PyBytesWriter_GetSize(_PyBytesWriter *writer, char *str)
Py_LOCAL_INLINE(int)
_PyBytesWriter_CheckConsistency(_PyBytesWriter *writer, char *str)
{
char *start, *end;
const char *start, *end;
if (writer->use_small_buffer) {
assert(writer->buffer == NULL);