diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-04-12 11:58:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-12 11:58:27 (GMT) |
commit | 8f87eefe7f0576c05c488874eb9601a7a87c7312 (patch) | |
tree | 10ea36d1f702ae9e8bc34bcc88588868706948f6 /Modules | |
parent | 3e0dd3730b5eff7e9ae6fb921aa77cd26efc9e3a (diff) | |
download | cpython-8f87eefe7f0576c05c488874eb9601a7a87c7312.zip cpython-8f87eefe7f0576c05c488874eb9601a7a87c7312.tar.gz cpython-8f87eefe7f0576c05c488874eb9601a7a87c7312.tar.bz2 |
bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. (GH-19472)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 2 | ||||
-rw-r--r-- | Modules/_ctypes/callproc.c | 2 | ||||
-rw-r--r-- | Modules/_ctypes/cfield.c | 4 | ||||
-rw-r--r-- | Modules/_cursesmodule.c | 8 | ||||
-rw-r--r-- | Modules/_elementtree.c | 2 | ||||
-rw-r--r-- | Modules/_io/bytesio.c | 4 | ||||
-rw-r--r-- | Modules/_io/textio.c | 2 | ||||
-rw-r--r-- | Modules/_localemodule.c | 2 | ||||
-rw-r--r-- | Modules/_sqlite/connection.c | 2 | ||||
-rw-r--r-- | Modules/_ssl.c | 2 | ||||
-rw-r--r-- | Modules/_struct.c | 4 | ||||
-rw-r--r-- | Modules/_tkinter.c | 4 | ||||
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 2 | ||||
-rw-r--r-- | Modules/readline.c | 4 |
14 files changed, 22 insertions, 22 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index ba5ef39..5548c50 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1310,7 +1310,7 @@ CharArray_get_value(CDataObject *self, void *Py_UNUSED(ignored)) static int CharArray_set_value(CDataObject *self, PyObject *value, void *Py_UNUSED(ignored)) { - char *ptr; + const char *ptr; Py_ssize_t size; if (value == NULL) { diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index d1c552a..815fc66 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1384,7 +1384,7 @@ copy_com_pointer(PyObject *self, PyObject *args) static PyObject *py_dl_open(PyObject *self, PyObject *args) { PyObject *name, *name2; - char *name_str; + const char *name_str; void * handle; #if HAVE_DECL_RTLD_LOCAL int mode = RTLD_NOW | RTLD_LOCAL; diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index f860e6e..2060d15 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1283,7 +1283,7 @@ s_get(void *ptr, Py_ssize_t size) static PyObject * s_set(void *ptr, PyObject *value, Py_ssize_t length) { - char *data; + const char *data; Py_ssize_t size; if(!PyBytes_Check(value)) { @@ -1321,7 +1321,7 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size) return value; } if (PyBytes_Check(value)) { - *(char **)ptr = PyBytes_AsString(value); + *(const char **)ptr = PyBytes_AsString(value); Py_INCREF(value); return value; } else if (PyLong_Check(value)) { diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index ca6a89f..08991fd 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -709,7 +709,7 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, else #endif { - char *str = PyBytes_AS_STRING(bytesobj); + const char *str = PyBytes_AS_STRING(bytesobj); funcname = "addstr"; if (use_xy) rtn = mvwaddstr(self->win,y,x,str); @@ -792,7 +792,7 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, else #endif { - char *str = PyBytes_AS_STRING(bytesobj); + const char *str = PyBytes_AS_STRING(bytesobj); funcname = "addnstr"; if (use_xy) rtn = mvwaddnstr(self->win,y,x,str,n); @@ -1710,7 +1710,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, else #endif { - char *str = PyBytes_AS_STRING(bytesobj); + const char *str = PyBytes_AS_STRING(bytesobj); funcname = "insstr"; if (use_xy) rtn = mvwinsstr(self->win,y,x,str); @@ -1795,7 +1795,7 @@ _curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, else #endif { - char *str = PyBytes_AS_STRING(bytesobj); + const char *str = PyBytes_AS_STRING(bytesobj); funcname = "insnstr"; if (use_xy) rtn = mvwinsnstr(self->win,y,x,str,n); diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index c0c741e..10d78dd 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1153,7 +1153,7 @@ checkpath(PyObject* tag) return 0; } if (PyBytes_Check(tag)) { - char *p = PyBytes_AS_STRING(tag); + const char *p = PyBytes_AS_STRING(tag); const Py_ssize_t len = PyBytes_GET_SIZE(tag); if (len >= 3 && p[0] == '{' && ( p[1] == '}' || (p[1] == '*' && p[2] == '}'))) { diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index b5d308a..f4261b3 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -393,7 +393,7 @@ _io_BytesIO_tell_impl(bytesio *self) static PyObject * read_bytes(bytesio *self, Py_ssize_t size) { - char *output; + const char *output; assert(self->buf != NULL); assert(size <= self->string_size); @@ -502,7 +502,7 @@ _io_BytesIO_readlines_impl(bytesio *self, PyObject *arg) { Py_ssize_t maxsize, size, n; PyObject *result, *line; - char *output; + const char *output; CHECK_CLOSED(self); diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 12dba38..92d6faa 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -2640,7 +2640,7 @@ _io_TextIOWrapper_tell_impl(textio *self) Py_ssize_t chars_to_skip, chars_decoded; Py_ssize_t skip_bytes, skip_back; PyObject *saved_state = NULL; - char *input, *input_end; + const char *input, *input_end; Py_ssize_t dec_buffer_len; int dec_flags; diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 5bf6638..0819d0e 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -637,7 +637,7 @@ PyDoc_STRVAR(bindtextdomain__doc__, static PyObject* PyIntl_bindtextdomain(PyObject* self, PyObject*args) { - char *domain, *dirname, *current_dirname; + const char *domain, *dirname, *current_dirname; PyObject *dirname_obj, *dirname_bytes = NULL, *result; if (!PyArg_ParseTuple(args, "sO", &domain, &dirname_obj)) diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 92bdfe3..91041b9 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -79,7 +79,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject NULL }; - char* database; + const char* database; PyObject* database_obj; int detect_types = 0; PyObject* isolation_level = NULL; diff --git a/Modules/_ssl.c b/Modules/_ssl.c index ef04712..a471a26 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -4037,7 +4037,7 @@ error: /* internal helper function, returns -1 on error */ static int -_add_ca_certs(PySSLContext *self, void *data, Py_ssize_t len, +_add_ca_certs(PySSLContext *self, const void *data, Py_ssize_t len, int filetype) { BIO *biobuf = NULL; diff --git a/Modules/_struct.c b/Modules/_struct.c index 242ca9c..82ac0a1 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1785,7 +1785,7 @@ s_pack_internal(PyStructObject *soself, PyObject *const *args, int offset, char* if (e->format == 's') { Py_ssize_t n; int isstring; - void *p; + const void *p; isstring = PyBytes_Check(v); if (!isstring && !PyByteArray_Check(v)) { PyErr_SetString(_structmodulestate_global->StructError, @@ -1807,7 +1807,7 @@ s_pack_internal(PyStructObject *soself, PyObject *const *args, int offset, char* } else if (e->format == 'p') { Py_ssize_t n; int isstring; - void *p; + const void *p; isstring = PyBytes_Check(v); if (!isstring && !PyByteArray_Check(v)) { PyErr_SetString(_structmodulestate_global->StructError, diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 5f001c6..199ae4f 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -574,9 +574,9 @@ SplitObj(PyObject *arg) else if (PyBytes_Check(arg)) { int argc; const char **argv; - char *list = PyBytes_AS_STRING(arg); + const char *list = PyBytes_AS_STRING(arg); - if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) { + if (Tcl_SplitList((Tcl_Interp *)NULL, (char *)list, &argc, &argv) != TCL_OK) { Py_INCREF(arg); return arg; } diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 9f9fbeb..319dc52 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -1246,7 +1246,7 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDe PyObject *buffer; PyLongObject *statelong; Py_ssize_t buffersize; - char *bufferstr; + const char *bufferstr; unsigned char statebytes[8]; if (!PyArg_ParseTuple(state, "SO!;setstate(): illegal state argument", diff --git a/Modules/readline.c b/Modules/readline.c index 225d06b..12d6cc7 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -234,7 +234,7 @@ static PyObject * write_history_file(PyObject *self, PyObject *args) { PyObject *filename_obj = Py_None, *filename_bytes; - char *filename; + const char *filename; int err; if (!PyArg_ParseTuple(args, "|O:write_history_file", &filename_obj)) return NULL; @@ -270,7 +270,7 @@ append_history_file(PyObject *self, PyObject *args) { int nelements; PyObject *filename_obj = Py_None, *filename_bytes; - char *filename; + const char *filename; int err; if (!PyArg_ParseTuple(args, "i|O:append_history_file", &nelements, &filename_obj)) return NULL; |