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

This commit is contained in:
Serhiy Storchaka 2020-04-11 10:48:40 +03:00 committed by GitHub
parent 7ec43a7309
commit cd8295ff75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 250 additions and 221 deletions

View file

@ -1265,12 +1265,14 @@ PyBytes_Repr(PyObject *obj, int smartquotes)
Py_ssize_t i, length = Py_SIZE(op);
Py_ssize_t newsize, squotes, dquotes;
PyObject *v;
unsigned char quote, *s, *p;
unsigned char quote;
const unsigned char *s;
Py_UCS1 *p;
/* Compute size of output string */
squotes = dquotes = 0;
newsize = 3; /* b'' */
s = (unsigned char*)op->ob_sval;
s = (const unsigned char*)op->ob_sval;
for (i = 0; i < length; i++) {
Py_ssize_t incr = 1;
switch(s[i]) {
@ -2271,7 +2273,7 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
char *buf;
Py_ssize_t hexlen, invalid_char;
unsigned int top, bot;
Py_UCS1 *str, *end;
const Py_UCS1 *str, *end;
_PyBytesWriter writer;
_PyBytesWriter_Init(&writer);
@ -2283,7 +2285,7 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
hexlen = PyUnicode_GET_LENGTH(string);
if (!PyUnicode_IS_ASCII(string)) {
void *data = PyUnicode_DATA(string);
const void *data = PyUnicode_DATA(string);
unsigned int kind = PyUnicode_KIND(string);
Py_ssize_t i;