diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-04-11 07:48:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 07:48:40 (GMT) |
commit | cd8295ff758891f21084a6a5ad3403d35dda38f7 (patch) | |
tree | a77f829dea34198a7f36658c6e22baf4bc0bf5f5 /Objects/bytesobject.c | |
parent | 7ec43a73092d43c6c95e7dd2669f49d54b57966f (diff) | |
download | cpython-cd8295ff758891f21084a6a5ad3403d35dda38f7.zip cpython-cd8295ff758891f21084a6a5ad3403d35dda38f7.tar.gz cpython-cd8295ff758891f21084a6a5ad3403d35dda38f7.tar.bz2 |
bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode data. (GH-19345)
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 03cd7dd..987d98d 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -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; |