Added the const qualifier to char* variables that refer to readonly internal
UTF-8 represenatation of Unicode objects.
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 4807e4f..de1ae3d 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1829,7 +1829,7 @@
PyCSimpleType_paramfunc(CDataObject *self)
{
StgDictObject *dict;
- char *fmt;
+ const char *fmt;
PyCArgObject *parg;
struct fielddesc *fd;
@@ -2039,7 +2039,7 @@
PyCSimpleType_from_param(PyObject *type, PyObject *value)
{
StgDictObject *dict;
- char *fmt;
+ const char *fmt;
PyCArgObject *parg;
struct fielddesc *fd;
PyObject *as_parameter;
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 716d1e9..53cfa79 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -488,8 +488,8 @@
bitsize = 0;
if (isStruct && !isPacked) {
- char *fieldfmt = dict->format ? dict->format : "B";
- char *fieldname = PyUnicode_AsUTF8(name);
+ const char *fieldfmt = dict->format ? dict->format : "B";
+ const char *fieldname = PyUnicode_AsUTF8(name);
char *ptr;
Py_ssize_t len;
char *buf;
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 5937520..71245c2 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -3613,7 +3613,7 @@
for (i = 0; i < PySequence_Size(events_seq); ++i) {
PyObject *event_name_obj = PySequence_Fast_GET_ITEM(events_seq, i);
- char *event_name = NULL;
+ const char *event_name = NULL;
if (PyUnicode_Check(event_name_obj)) {
event_name = PyUnicode_AsUTF8(event_name_obj);
} else if (PyBytes_Check(event_name_obj)) {
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index c760522..2b43fd8 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -305,7 +305,7 @@
"could not acquire lock for %A at interpreter "
"shutdown, possibly due to daemon threads",
(PyObject *) self);
- char *msg = PyUnicode_AsUTF8(msgobj);
+ const char *msg = PyUnicode_AsUTF8(msgobj);
Py_FatalError(msg);
}
return 1;
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c
index 8542efd..93c8b47 100644
--- a/Modules/_io/stringio.c
+++ b/Modules/_io/stringio.c
@@ -693,7 +693,7 @@
PyObject *newline_obj)
/*[clinic end generated code: output=a421ea023b22ef4e input=cee2d9181b2577a3]*/
{
- char *newline = "\n";
+ const char *newline = "\n";
Py_ssize_t value_len;
/* Parse the newline argument. We only want to allow unicode objects or
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 79113e0..d6d5cca 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1941,7 +1941,7 @@
goto error;
}
else {
- char *string;
+ const char *string;
/* proto < 2: write the repr and newline. This is quadratic-time (in
the number of digits), in both directions. We add a trailing 'L'
@@ -2218,7 +2218,7 @@
{
PyObject *encoded = NULL;
Py_ssize_t size;
- char *data;
+ const char *data;
int r;
if (PyUnicode_READY(obj))
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 1c6aa54..4cd3cb3 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -1489,7 +1489,7 @@
PyObject* retval;
Py_ssize_t i, len;
_Py_IDENTIFIER(upper);
- char *uppercase_name_str;
+ const char *uppercase_name_str;
int rc;
unsigned int kind;
void *data;
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 53342f3..c6c3e98 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -79,12 +79,12 @@
PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
{
Py_ssize_t _idx;
- char* key;
+ const char *key;
Py_ssize_t nitems, i;
- char* compare_key;
+ const char *compare_key;
- char* p1;
- char* p2;
+ const char *p1;
+ const char *p2;
PyObject* item;
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 0df661b..8b45a03 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -112,7 +112,7 @@
int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter)
{
int rc = SQLITE_OK;
- char* string;
+ const char *string;
Py_ssize_t buflen;
parameter_type paramtype;
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 3e96aa0..f69a4df 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -536,7 +536,7 @@
else if (PyUnicode_Check(arg)) {
int argc;
const char **argv;
- char *list = PyUnicode_AsUTF8(arg);
+ const char *list = PyUnicode_AsUTF8(arg);
if (list == NULL ||
Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
@@ -993,7 +993,7 @@
Tcl_Obj *result;
int neg;
PyObject *hexstr;
- char *hexchars;
+ const char *hexchars;
mp_int bigValue;
neg = Py_SIZE(value) < 0;
@@ -1723,7 +1723,7 @@
static int
varname_converter(PyObject *in, void *_out)
{
- char *s;
+ const char *s;
const char **out = (const char**)_out;
if (PyBytes_Check(in)) {
if (PyBytes_GET_SIZE(in) > INT_MAX) {
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index feaa212..7f6cd4d 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -5982,7 +5982,7 @@
PyObject *hobj = NULL;
PyObject *pobj = (PyObject *)NULL;
char pbuf[30];
- char *hptr, *pptr;
+ const char *hptr, *pptr;
int family, socktype, protocol, flags;
int error;
PyObject *all = (PyObject *)NULL;
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index 7afca58..412e436 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -116,7 +116,7 @@
long facility = LOG_USER;
PyObject *new_S_ident_o = NULL;
static char *keywords[] = {"ident", "logoption", "facility", 0};
- char *ident = NULL;
+ const char *ident = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|Ull:openlog", keywords, &new_S_ident_o, &logopt, &facility))