summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-25 18:01:53 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-25 18:01:53 (GMT)
commitef1585eb9a488ae8ce3ff057f43a7048b941cc1c (patch)
treefbbdc44ba78d84a31d5fc0bf1679870ec4f32f77 /Modules
parent2d06e8445587d9b4d0bf79bdb08ab4743b780249 (diff)
downloadcpython-ef1585eb9a488ae8ce3ff057f43a7048b941cc1c.zip
cpython-ef1585eb9a488ae8ce3ff057f43a7048b941cc1c.tar.gz
cpython-ef1585eb9a488ae8ce3ff057f43a7048b941cc1c.tar.bz2
Issue #25923: Added more const qualifiers to signatures of static and private functions.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c4
-rw-r--r--Modules/_ctypes/callbacks.c2
-rw-r--r--Modules/_ctypes/callproc.c2
-rw-r--r--Modules/_ctypes/ctypes.h2
-rw-r--r--Modules/_curses_panel.c2
-rw-r--r--Modules/_datetimemodule.c2
-rw-r--r--Modules/_io/_iomodule.h2
-rw-r--r--Modules/_io/bufferedio.c2
-rw-r--r--Modules/_io/fileio.c4
-rw-r--r--Modules/_io/textio.c20
-rw-r--r--Modules/_json.c4
-rw-r--r--Modules/_localemodule.c2
-rw-r--r--Modules/_pickle.c2
-rw-r--r--Modules/_posixsubprocess.c2
-rw-r--r--Modules/_scproxy.c2
-rw-r--r--Modules/_sre.c2
-rw-r--r--Modules/_ssl.c4
-rw-r--r--Modules/_struct.c6
-rw-r--r--Modules/_testmultiphase.c2
-rw-r--r--Modules/_tkinter.c8
-rw-r--r--Modules/_winapi.c4
-rw-r--r--Modules/binascii.c44
-rw-r--r--Modules/gcmodule.c2
-rw-r--r--Modules/getaddrinfo.c2
-rw-r--r--Modules/main.c2
-rw-r--r--Modules/mathmodule.c4
-rw-r--r--Modules/parsermodule.c10
-rw-r--r--Modules/posixmodule.c43
-rw-r--r--Modules/pyexpat.c6
-rw-r--r--Modules/socketmodule.c4
-rw-r--r--Modules/timemodule.c2
-rw-r--r--Modules/xxlimited.c2
-rw-r--r--Modules/xxmodule.c2
-rw-r--r--Modules/zipimport.c2
-rw-r--r--Modules/zlibmodule.c2
35 files changed, 112 insertions, 95 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index fccc8ba..ac5e5fa 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3195,7 +3195,7 @@ _validate_paramflags(PyTypeObject *type, PyObject *paramflags)
}
static int
-_get_name(PyObject *obj, char **pname)
+_get_name(PyObject *obj, const char **pname)
{
#ifdef MS_WIN32
if (PyLong_Check(obj)) {
@@ -3223,7 +3223,7 @@ _get_name(PyObject *obj, char **pname)
static PyObject *
PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- char *name;
+ const char *name;
int (* address)(void);
PyObject *ftuple;
PyObject *dll;
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 7cd6164..00e8e66 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -77,7 +77,7 @@ PyTypeObject PyCThunk_Type = {
/**************************************************************/
static void
-PrintError(char *msg, ...)
+PrintError(const char *msg, ...)
{
char buf[512];
PyObject *f = PySys_GetObject("stderr");
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 68981fe..870a0d4 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -928,7 +928,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
* Raise a new exception 'exc_class', adding additional text to the original
* exception string.
*/
-void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...)
+void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
{
va_list vargs;
PyObject *tp, *v, *tb, *s, *cls_str, *msg_str;
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
index 0d3f724..b06ba8a 100644
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -327,7 +327,7 @@ extern int
PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
Py_ssize_t index, Py_ssize_t size, char *ptr);
-extern void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...);
+extern void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...);
struct basespec {
CDataObject *base;
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
index a9c406f..26bf094 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -56,7 +56,7 @@ static struct PyModuleDef _curses_panelmodule;
*/
static PyObject *
-PyCursesCheckERR(int code, char *fname)
+PyCursesCheckERR(int code, const char *fname)
{
if (code != ERR) {
Py_INCREF(Py_None);
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index e8b7ae8..3e5e195 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -873,7 +873,7 @@ get_tzinfo_member(PyObject *self)
* this returns NULL. Else result is returned.
*/
static PyObject *
-call_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg)
+call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg)
{
PyObject *offset;
diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h
index 0c6eae2..3c48ff3 100644
--- a/Modules/_io/_iomodule.h
+++ b/Modules/_io/_iomodule.h
@@ -60,7 +60,7 @@ extern PyObject *_PyIncrementalNewlineDecoder_decode(
* Otherwise, the line ending is specified by readnl, a str object */
extern Py_ssize_t _PyIO_find_line_ending(
int translated, int universal, PyObject *readnl,
- int kind, char *start, char *end, Py_ssize_t *consumed);
+ int kind, const char *start, const char *end, Py_ssize_t *consumed);
/* Return 1 if an EnvironmentError with errno == EINTR is set (and then
clears the error indicator), 0 otherwise.
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 6bb2200..16f8cdf 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -659,7 +659,7 @@ _bufferedreader_raw_read(buffered *self, char *start, Py_ssize_t len);
/* Sets the current error to BlockingIOError */
static void
-_set_BlockingIOError(char *msg, Py_ssize_t written)
+_set_BlockingIOError(const char *msg, Py_ssize_t written)
{
PyObject *err;
PyErr_Clear();
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index dbd604a..8bf3922 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -540,7 +540,7 @@ err_closed(void)
}
static PyObject *
-err_mode(char *action)
+err_mode(const char *action)
{
_PyIO_State *state = IO_STATE();
if (state != NULL)
@@ -1043,7 +1043,7 @@ _io_FileIO_truncate_impl(fileio *self, PyObject *posobj)
}
#endif /* HAVE_FTRUNCATE */
-static char *
+static const char *
mode_string(fileio *self)
{
if (self->created) {
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index d018623..140da10 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1648,8 +1648,8 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
/* NOTE: `end` must point to the real end of the Py_UCS4 storage,
that is to the NUL character. Otherwise the function will produce
incorrect results. */
-static char *
-find_control_char(int kind, char *s, char *end, Py_UCS4 ch)
+static const char *
+find_control_char(int kind, const char *s, const char *end, Py_UCS4 ch)
{
if (kind == PyUnicode_1BYTE_KIND) {
assert(ch < 256);
@@ -1669,13 +1669,13 @@ find_control_char(int kind, char *s, char *end, Py_UCS4 ch)
Py_ssize_t
_PyIO_find_line_ending(
int translated, int universal, PyObject *readnl,
- int kind, char *start, char *end, Py_ssize_t *consumed)
+ int kind, const char *start, const char *end, Py_ssize_t *consumed)
{
Py_ssize_t len = ((char*)end - (char*)start)/kind;
if (translated) {
/* Newlines are already translated, only search for \n */
- char *pos = find_control_char(kind, start, end, '\n');
+ const char *pos = find_control_char(kind, start, end, '\n');
if (pos != NULL)
return (pos - start)/kind + 1;
else {
@@ -1687,7 +1687,7 @@ _PyIO_find_line_ending(
/* Universal newline search. Find any of \r, \r\n, \n
* The decoder ensures that \r\n are not split in two pieces
*/
- char *s = start;
+ const char *s = start;
for (;;) {
Py_UCS4 ch;
/* Fast path for non-control chars. The loop always ends
@@ -1717,21 +1717,21 @@ _PyIO_find_line_ending(
/* Assume that readnl is an ASCII character. */
assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND);
if (readnl_len == 1) {
- char *pos = find_control_char(kind, start, end, nl[0]);
+ const char *pos = find_control_char(kind, start, end, nl[0]);
if (pos != NULL)
return (pos - start)/kind + 1;
*consumed = len;
return -1;
}
else {
- char *s = start;
- char *e = end - (readnl_len - 1)*kind;
- char *pos;
+ const char *s = start;
+ const char *e = end - (readnl_len - 1)*kind;
+ const char *pos;
if (e < s)
e = s;
while (s < e) {
Py_ssize_t i;
- char *pos = find_control_char(kind, s, end, nl[0]);
+ const char *pos = find_control_char(kind, s, end, nl[0]);
if (pos == NULL || pos >= e)
break;
for (i = 1; i < readnl_len; i++) {
diff --git a/Modules/_json.c b/Modules/_json.c
index f63d758..3c857ae 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -112,7 +112,7 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc, PyObject *dct, Py_ssiz
static PyObject *
_encoded_const(PyObject *obj);
static void
-raise_errmsg(char *msg, PyObject *s, Py_ssize_t end);
+raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end);
static PyObject *
encoder_encode_string(PyEncoderObject *s, PyObject *obj);
static PyObject *
@@ -323,7 +323,7 @@ escape_unicode(PyObject *pystr)
}
static void
-raise_errmsg(char *msg, PyObject *s, Py_ssize_t end)
+raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end)
{
/* Use JSONDecodeError exception to raise a nice looking ValueError subclass */
static PyObject *JSONDecodeError = NULL;
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index b1d6add..a92fb10 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -49,7 +49,7 @@ PyDoc_STRVAR(setlocale__doc__,
/* the grouping is terminated by either 0 or CHAR_MAX */
static PyObject*
-copy_grouping(char* s)
+copy_grouping(const char* s)
{
int i;
PyObject *result, *val = NULL;
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 487b533..9d36346 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2187,7 +2187,7 @@ error:
}
static int
-write_utf8(PicklerObject *self, char *data, Py_ssize_t size)
+write_utf8(PicklerObject *self, const char *data, Py_ssize_t size)
{
char header[9];
Py_ssize_t len;
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 8bedab5..a0109fb 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -72,7 +72,7 @@ _enable_gc(int need_to_reenable_gc, PyObject *gc_module)
/* Convert ASCII to a positive int, no libc call. no overflow. -1 on error. */
static int
-_pos_int_from_ascii(char *name)
+_pos_int_from_ascii(const char *name)
{
int num = 0;
while (*name >= '0' && *name <= '9') {
diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c
index 66b6e34..68be458 100644
--- a/Modules/_scproxy.c
+++ b/Modules/_scproxy.c
@@ -130,7 +130,7 @@ error:
}
static int
-set_proxy(PyObject* proxies, char* proto, CFDictionaryRef proxyDict,
+set_proxy(PyObject* proxies, const char* proto, CFDictionaryRef proxyDict,
CFStringRef enabledKey,
CFStringRef hostKey, CFStringRef portKey)
{
diff --git a/Modules/_sre.c b/Modules/_sre.c
index f597a70..fb0ab03 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -714,7 +714,7 @@ _sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string,
}
static PyObject*
-call(char* module, char* function, PyObject* args)
+call(const char* module, const char* function, PyObject* args)
{
PyObject* name;
PyObject* mod;
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 8818d26..5968ed5 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -378,7 +378,7 @@ fail:
}
static PyObject *
-PySSL_SetError(PySSLSocket *obj, int ret, char *filename, int lineno)
+PySSL_SetError(PySSLSocket *obj, int ret, const char *filename, int lineno)
{
PyObject *type = PySSLErrorObject;
char *errstr = NULL;
@@ -460,7 +460,7 @@ PySSL_SetError(PySSLSocket *obj, int ret, char *filename, int lineno)
}
static PyObject *
-_setSSLError (char *errstr, int errcode, char *filename, int lineno) {
+_setSSLError (const char *errstr, int errcode, const char *filename, int lineno) {
if (errstr == NULL)
errcode = ERR_peek_last_error();
diff --git a/Modules/_struct.c b/Modules/_struct.c
index b18c71d..820e004 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -1189,7 +1189,7 @@ static formatdef lilendian_table[] = {
static const formatdef *
-whichtable(char **pfmt)
+whichtable(const char **pfmt)
{
const char *fmt = (*pfmt)++; /* May be backed out of later */
switch (*fmt) {
@@ -1268,7 +1268,7 @@ prepare_s(PyStructObject *self)
fmt = PyBytes_AS_STRING(self->s_format);
- f = whichtable((char **)&fmt);
+ f = whichtable(&fmt);
s = fmt;
size = 0;
@@ -1457,7 +1457,7 @@ s_dealloc(PyStructObject *s)
}
static PyObject *
-s_unpack_internal(PyStructObject *soself, char *startfrom) {
+s_unpack_internal(PyStructObject *soself, const char *startfrom) {
formatcode *code;
Py_ssize_t i = 0;
PyObject *result = PyTuple_New(soself->s_len);
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
index 2005205..03eda27 100644
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -61,7 +61,7 @@ Example_getattro(ExampleObject *self, PyObject *name)
}
static int
-Example_setattr(ExampleObject *self, char *name, PyObject *v)
+Example_setattr(ExampleObject *self, const char *name, PyObject *v)
{
if (self->x_attr == NULL) {
self->x_attr = PyDict_New();
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 41ad5f9..768df81 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -841,7 +841,7 @@ PyTclObject_dealloc(PyTclObject *self)
Py_DECREF(tp);
}
-static char*
+static const char *
PyTclObject_TclString(PyObject *self)
{
return Tcl_GetString(((PyTclObject*)self)->value);
@@ -1726,7 +1726,7 @@ static int
varname_converter(PyObject *in, void *_out)
{
char *s;
- char **out = (char**)_out;
+ const char **out = (const char**)_out;
if (PyBytes_Check(in)) {
if (PyBytes_Size(in) > INT_MAX) {
PyErr_SetString(PyExc_OverflowError, "bytes object is too long");
@@ -1846,7 +1846,7 @@ var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
static PyObject *
SetVar(PyObject *self, PyObject *args, int flags)
{
- char *name1, *name2;
+ const char *name1, *name2;
PyObject *newValue;
PyObject *res = NULL;
Tcl_Obj *newval, *ok;
@@ -1915,7 +1915,7 @@ Tkapp_GlobalSetVar(PyObject *self, PyObject *args)
static PyObject *
GetVar(PyObject *self, PyObject *args, int flags)
{
- char *name1, *name2=NULL;
+ const char *name1, *name2=NULL;
PyObject *res = NULL;
Tcl_Obj *tres;
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 3e7f187..c4d4264 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -675,7 +675,7 @@ _winapi_CreatePipe_impl(PyModuleDef *module, PyObject *pipe_attrs,
/* helpers for createprocess */
static unsigned long
-getulong(PyObject* obj, char* name)
+getulong(PyObject* obj, const char* name)
{
PyObject* value;
unsigned long ret;
@@ -691,7 +691,7 @@ getulong(PyObject* obj, char* name)
}
static HANDLE
-gethandle(PyObject* obj, char* name)
+gethandle(PyObject* obj, const char* name)
{
PyObject* value;
HANDLE ret;
diff --git a/Modules/binascii.c b/Modules/binascii.c
index 9df48da..a306acd 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -256,7 +256,8 @@ static PyObject *
binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=5779f39b0b48459f input=7cafeaf73df63d1c]*/
{
- unsigned char *ascii_data, *bin_data;
+ const unsigned char *ascii_data;
+ unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
@@ -342,7 +343,8 @@ static PyObject *
binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=181021b69bb9a414 input=00fdf458ce8b465b]*/
{
- unsigned char *ascii_data, *bin_data;
+ unsigned char *ascii_data;
+ const unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
@@ -389,7 +391,7 @@ binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data)
static int
-binascii_find_valid(unsigned char *s, Py_ssize_t slen, int num)
+binascii_find_valid(const unsigned char *s, Py_ssize_t slen, int num)
{
/* Finds & returns the (num+1)th
** valid character for base64, or -1 if none.
@@ -426,7 +428,8 @@ static PyObject *
binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=3e351b702bed56d2 input=5872acf6e1cac243]*/
{
- unsigned char *ascii_data, *bin_data;
+ const unsigned char *ascii_data;
+ unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
@@ -522,7 +525,8 @@ static PyObject *
binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline)
/*[clinic end generated code: output=19e1dd719a890b50 input=7b2ea6fa38d8924c]*/
{
- unsigned char *ascii_data, *bin_data;
+ unsigned char *ascii_data;
+ const unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
@@ -589,7 +593,8 @@ static PyObject *
binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=60bcdbbd28b105cd input=0d914c680e0eed55]*/
{
- unsigned char *ascii_data, *bin_data;
+ const unsigned char *ascii_data;
+ unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
@@ -667,7 +672,8 @@ static PyObject *
binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=0905da344dbf0648 input=e1f1712447a82b09]*/
{
- unsigned char *in_data, *out_data;
+ const unsigned char *in_data;
+ unsigned char *out_data;
unsigned char ch;
Py_ssize_t in, inend, len;
_PyBytesWriter writer;
@@ -728,7 +734,8 @@ static PyObject *
binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=5a987810d5e3cdbb input=9596ebe019fe12ba]*/
{
- unsigned char *ascii_data, *bin_data;
+ unsigned char *ascii_data;
+ const unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
@@ -782,7 +789,8 @@ static PyObject *
binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=f7afd89b789946ab input=54cdd49fc014402c]*/
{
- unsigned char *in_data, *out_data;
+ const unsigned char *in_data;
+ unsigned char *out_data;
unsigned char in_byte, in_repeat;
Py_ssize_t in_len;
_PyBytesWriter writer;
@@ -899,7 +907,7 @@ static unsigned int
binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
/*[clinic end generated code: output=167c2dac62625717 input=add8c53712ccceda]*/
{
- unsigned char *bin_data;
+ const unsigned char *bin_data;
Py_ssize_t len;
crc &= 0xffff;
@@ -1050,7 +1058,7 @@ binascii_crc32_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
#ifdef USE_ZLIB_CRC32
/* This was taken from zlibmodule.c PyZlib_crc32 (but is PY_SSIZE_T_CLEAN) */
{
- Byte *buf;
+ const Byte *buf;
Py_ssize_t len;
int signed_val;
@@ -1061,7 +1069,7 @@ binascii_crc32_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
}
#else /* USE_ZLIB_CRC32 */
{ /* By Jim Ahlstrom; All rights transferred to CNRI */
- unsigned char *bin_data;
+ const unsigned char *bin_data;
Py_ssize_t len;
unsigned int result;
@@ -1144,7 +1152,7 @@ static PyObject *
binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr)
/*[clinic end generated code: output=d61da452b5c6d290 input=9e1e7f2f94db24fd]*/
{
- char* argbuf;
+ const char* argbuf;
Py_ssize_t arglen;
PyObject *retval;
char* retbuf;
@@ -1232,7 +1240,8 @@ binascii_a2b_qp_impl(PyModuleDef *module, Py_buffer *data, int header)
{
Py_ssize_t in, out;
char ch;
- unsigned char *ascii_data, *odata;
+ const unsigned char *ascii_data;
+ unsigned char *odata;
Py_ssize_t datalen = 0;
PyObject *rv;
@@ -1338,13 +1347,14 @@ binascii_b2a_qp_impl(PyModuleDef *module, Py_buffer *data, int quotetabs,
/*[clinic end generated code: output=a87ca9ccb94e2a9f input=7f2a9aaa008e92b2]*/
{
Py_ssize_t in, out;
- unsigned char *databuf, *odata;
+ const unsigned char *databuf;
+ unsigned char *odata;
Py_ssize_t datalen = 0, odatalen = 0;
PyObject *rv;
unsigned int linelen = 0;
unsigned char ch;
int crlf = 0;
- unsigned char *p;
+ const unsigned char *p;
databuf = data->buf;
datalen = data->len;
@@ -1353,7 +1363,7 @@ binascii_b2a_qp_impl(PyModuleDef *module, Py_buffer *data, int quotetabs,
/* XXX: this function has the side effect of converting all of
* the end of lines to be the same depending on this detection
* here */
- p = (unsigned char *) memchr(databuf, '\n', datalen);
+ p = (const unsigned char *) memchr(databuf, '\n', datalen);
if ((p != NULL) && (p > databuf) && (*(p-1) == '\r'))
crlf = 1;
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index cb7222d..0c6f444 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -738,7 +738,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old)
}
static void
-debug_cycle(char *msg, PyObject *op)
+debug_cycle(const char *msg, PyObject *op)
{
PySys_FormatStderr("gc: %s <%s %p>\n",
msg, Py_TYPE(op)->tp_name, op);
diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c
index 33d7078..13a9e40 100644
--- a/Modules/getaddrinfo.c
+++ b/Modules/getaddrinfo.c
@@ -198,7 +198,7 @@ if (pai->ai_flags & AI_CANONNAME) {\
#define ERR(err) { error = (err); goto bad; }
-char *
+const char *
gai_strerror(int ecode)
{
if (ecode < 0 || ecode > EAI_MAX)
diff --git a/Modules/main.c b/Modules/main.c
index 4358cc8..35d07fd 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -103,7 +103,7 @@ PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n\
";
static int
-usage(int exitcode, wchar_t* program)
+usage(int exitcode, const wchar_t* program)
{
FILE *f = exitcode ? stderr : stdout;
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 9359eb2..6b3e139 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -876,7 +876,7 @@ math_1_to_int(PyObject *arg, double (*func) (double), int can_overflow)
}
static PyObject *
-math_2(PyObject *args, double (*func) (double, double), char *funcname)
+math_2(PyObject *args, double (*func) (double, double), const char *funcname)
{
PyObject *ox, *oy;
double x, y, r;
@@ -1673,7 +1673,7 @@ PyDoc_STRVAR(math_modf_doc,
in that int is larger than PY_SSIZE_T_MAX. */
static PyObject*
-loghelper(PyObject* arg, double (*func)(double), char *funcname)
+loghelper(PyObject* arg, double (*func)(double), const char *funcname)
{
/* If it is int, do it ourselves. */
if (PyLong_Check(arg)) {
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 4c5f2ef..deae049 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -578,13 +578,13 @@ parser_issuite(PyST_Object *self, PyObject *args, PyObject *kw)
}
-/* err_string(char* message)
+/* err_string(const char* message)
*
* Sets the error string for an exception of type ParserError.
*
*/
static void
-err_string(char *message)
+err_string(const char *message)
{
PyErr_SetString(parser_error, message);
}
@@ -597,7 +597,7 @@ err_string(char *message)
*
*/
static PyObject*
-parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type)
+parser_do_parse(PyObject *args, PyObject *kw, const char *argspec, int type)
{
char* string = 0;
PyObject* res = 0;
@@ -984,7 +984,7 @@ build_node_tree(PyObject *tuple)
/*
* Validation routines used within the validation section:
*/
-static int validate_terminal(node *terminal, int type, char *string);
+static int validate_terminal(node *terminal, int type, const char *string);
#define validate_ampersand(ch) validate_terminal(ch, AMPER, "&")
#define validate_circumflex(ch) validate_terminal(ch, CIRCUMFLEX, "^")
@@ -1082,7 +1082,7 @@ validate_numnodes(node *n, int num, const char *const name)
static int
-validate_terminal(node *terminal, int type, char *string)
+validate_terminal(node *terminal, int type, const char *string)
{
int res = (validate_ntype(terminal, type)
&& ((string == 0) || (strcmp(string, STR(terminal)) == 0)));
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 7a2b661..367e4f2 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -949,7 +949,8 @@ path_converter(PyObject *o, void *p) {
}
static void
-argument_unavailable_error(char *function_name, char *argument_name) {
+argument_unavailable_error(const char *function_name, const char *argument_name)
+{
PyErr_Format(PyExc_NotImplementedError,
"%s%s%s unavailable on this platform",
(function_name != NULL) ? function_name : "",
@@ -972,7 +973,8 @@ dir_fd_unavailable(PyObject *o, void *p)
}
static int
-fd_specified(char *function_name, int fd) {
+fd_specified(const char *function_name, int fd)
+{
if (fd == -1)
return 0;
@@ -981,7 +983,8 @@ fd_specified(char *function_name, int fd) {
}
static int
-follow_symlinks_specified(char *function_name, int follow_symlinks) {
+follow_symlinks_specified(const char *function_name, int follow_symlinks)
+{
if (follow_symlinks)
return 0;
@@ -990,7 +993,8 @@ follow_symlinks_specified(char *function_name, int follow_symlinks) {
}
static int
-path_and_dir_fd_invalid(char *function_name, path_t *path, int dir_fd) {
+path_and_dir_fd_invalid(const char *function_name, path_t *path, int dir_fd)
+{
if (!path->narrow && !path->wide && (dir_fd != DEFAULT_DIR_FD)) {
PyErr_Format(PyExc_ValueError,
"%s: can't specify dir_fd without matching path",
@@ -1001,7 +1005,8 @@ path_and_dir_fd_invalid(char *function_name, path_t *path, int dir_fd) {
}
static int
-dir_fd_and_fd_invalid(char *function_name, int dir_fd, int fd) {
+dir_fd_and_fd_invalid(const char *function_name, int dir_fd, int fd)
+{
if ((dir_fd != DEFAULT_DIR_FD) && (fd != -1)) {
PyErr_Format(PyExc_ValueError,
"%s: can't specify both dir_fd and fd",
@@ -1012,8 +1017,9 @@ dir_fd_and_fd_invalid(char *function_name, int dir_fd, int fd) {
}
static int
-fd_and_follow_symlinks_invalid(char *function_name, int fd,
- int follow_symlinks) {
+fd_and_follow_symlinks_invalid(const char *function_name, int fd,
+ int follow_symlinks)
+{
if ((fd > 0) && (!follow_symlinks)) {
PyErr_Format(PyExc_ValueError,
"%s: cannot use fd and follow_symlinks together",
@@ -1024,8 +1030,9 @@ fd_and_follow_symlinks_invalid(char *function_name, int fd,
}
static int
-dir_fd_and_follow_symlinks_invalid(char *function_name, int dir_fd,
- int follow_symlinks) {
+dir_fd_and_follow_symlinks_invalid(const char *function_name, int dir_fd,
+ int follow_symlinks)
+{
if ((dir_fd != DEFAULT_DIR_FD) && (!follow_symlinks)) {
PyErr_Format(PyExc_ValueError,
"%s: cannot use dir_fd and follow_symlinks together",
@@ -1220,7 +1227,7 @@ posix_error(void)
#ifdef MS_WINDOWS
static PyObject *
-win32_error(char* function, const char* filename)
+win32_error(const char* function, const char* filename)
{
/* XXX We should pass the function name along in the future.
(winreg.c also wants to pass the function name.)
@@ -1235,7 +1242,7 @@ win32_error(char* function, const char* filename)
}
static PyObject *
-win32_error_object(char* function, PyObject* filename)
+win32_error_object(const char* function, PyObject* filename)
{
/* XXX - see win32_error for comments on 'function' */
errno = GetLastError();
@@ -2100,7 +2107,7 @@ _pystat_fromstructstat(STRUCT_STAT *st)
static PyObject *
-posix_do_stat(char *function_name, path_t *path,
+posix_do_stat(const char *function_name, path_t *path,
int dir_fd, int follow_symlinks)
{
STRUCT_STAT st;
@@ -4561,7 +4568,7 @@ typedef struct {
#if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)
static int
-utime_dir_fd(utime_t *ut, int dir_fd, char *path, int follow_symlinks)
+utime_dir_fd(utime_t *ut, int dir_fd, const char *path, int follow_symlinks)
{
#ifdef HAVE_UTIMENSAT
int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW;
@@ -4610,7 +4617,7 @@ utime_fd(utime_t *ut, int fd)
#ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS
static int
-utime_nofollow_symlinks(utime_t *ut, char *path)
+utime_nofollow_symlinks(utime_t *ut, const char *path)
{
#ifdef HAVE_UTIMENSAT
UTIME_TO_TIMESPEC;
@@ -4626,7 +4633,7 @@ utime_nofollow_symlinks(utime_t *ut, char *path)
#ifndef MS_WINDOWS
static int
-utime_default(utime_t *ut, char *path)
+utime_default(utime_t *ut, const char *path)
{
#ifdef HAVE_UTIMENSAT
UTIME_TO_TIMESPEC;
@@ -7323,7 +7330,7 @@ _check_dirW(WCHAR *src, WCHAR *dest)
/* Return True if the path at src relative to dest is a directory */
static int
-_check_dirA(char *src, char *dest)
+_check_dirA(const char *src, char *dest)
{
WIN32_FILE_ATTRIBUTE_DATA src_info;
char dest_parent[MAX_PATH];
@@ -11835,7 +11842,7 @@ error:
#else /* POSIX */
static char *
-join_path_filename(char *path_narrow, char* filename, Py_ssize_t filename_len)
+join_path_filename(const char *path_narrow, const char* filename, Py_ssize_t filename_len)
{
Py_ssize_t path_len;
Py_ssize_t size;
@@ -11867,7 +11874,7 @@ join_path_filename(char *path_narrow, char* filename, Py_ssize_t filename_len)
}
static PyObject *
-DirEntry_from_posix_info(path_t *path, char *name, Py_ssize_t name_len,
+DirEntry_from_posix_info(path_t *path, const char *name, Py_ssize_t name_len,
ino_t d_ino
#ifdef HAVE_DIRENT_D_TYPE
, unsigned char d_type
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index b45e3da..9267c69 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -91,7 +91,7 @@ static struct HandlerInfo handler_info[64];
* false on an exception.
*/
static int
-set_error_attr(PyObject *err, char *name, int value)
+set_error_attr(PyObject *err, const char *name, int value)
{
PyObject *v = PyLong_FromLong(value);
@@ -218,7 +218,7 @@ flag_error(xmlparseobject *self)
}
static PyObject*
-call_with_frame(char *funcname, int lineno, PyObject* func, PyObject* args,
+call_with_frame(const char *funcname, int lineno, PyObject* func, PyObject* args,
xmlparseobject *self)
{
PyObject *res;
@@ -766,7 +766,7 @@ readinst(char *buf, int buf_size, PyObject *meth)
{
PyObject *str;
Py_ssize_t len;
- char *ptr;
+ const char *ptr;
str = PyObject_CallFunction(meth, "n", buf_size);
if (str == NULL)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index bae9634..7ab534e 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -904,7 +904,7 @@ static PyThread_type_lock netdb_lock;
an error occurred; then an exception is raised. */
static int
-setipaddr(char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af)
+setipaddr(const char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af)
{
struct addrinfo hints, *res;
int error;
@@ -1085,7 +1085,7 @@ makeipaddr(struct sockaddr *addr, int addrlen)
an error occurred. */
static int
-setbdaddr(char *name, bdaddr_t *bdaddr)
+setbdaddr(const char *name, bdaddr_t *bdaddr)
{
unsigned int b0, b1, b2, b3, b4, b5;
char ch;
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 31f0ce5..0b6d461 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -311,7 +311,7 @@ tmtotuple(struct tm *p)
Returns non-zero on success (parallels PyArg_ParseTuple).
*/
static int
-parse_time_t_args(PyObject *args, char *format, time_t *pwhen)
+parse_time_t_args(PyObject *args, const char *format, time_t *pwhen)
{
PyObject *ot = NULL;
time_t whent;
diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c
index 40c1760..c1a9be9 100644
--- a/Modules/xxlimited.c
+++ b/Modules/xxlimited.c
@@ -89,7 +89,7 @@ Xxo_getattro(XxoObject *self, PyObject *name)
}
static int
-Xxo_setattr(XxoObject *self, char *name, PyObject *v)
+Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
{
if (self->x_attr == NULL) {
self->x_attr = PyDict_New();
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index 85230d9..0764407 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -76,7 +76,7 @@ Xxo_getattro(XxoObject *self, PyObject *name)
}
static int
-Xxo_setattr(XxoObject *self, char *name, PyObject *v)
+Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
{
if (self->x_attr == NULL) {
self->x_attr = PyDict_New();
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 7220faf..87c8cfc 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -815,7 +815,7 @@ static PyTypeObject ZipImporter_Type = {
4 bytes, encoded as little endian. This partially reimplements
marshal.c:r_long() */
static long
-get_long(unsigned char *buf) {
+get_long(const unsigned char *buf) {
long x;
x = buf[0];
x |= (long)buf[1] << 8;
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index a15fdb2..7d2f55a 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -53,7 +53,7 @@ typedef struct
} compobject;
static void
-zlib_error(z_stream zst, int err, char *msg)
+zlib_error(z_stream zst, int err, const char *msg)
{
const char *zmsg = Z_NULL;
/* In case of a version mismatch, zst.msg won't be initialized.