Issue #25923: Added more const qualifiers to signatures of static and private functions.

This commit is contained in:
Serhiy Storchaka 2015-12-25 20:01:53 +02:00
parent 2d06e84455
commit ef1585eb9a
60 changed files with 210 additions and 191 deletions

View File

@ -17,9 +17,9 @@ extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len);
/* These store their len sized answer in the given preallocated *result arg. */ /* These store their len sized answer in the given preallocated *result arg. */
extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len); extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len); extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len); extern void _Py_bytes_title(char *result, const char *s, Py_ssize_t len);
extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len); extern void _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len);
extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len); extern void _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len);
/* The maketrans() static method. */ /* The maketrans() static method. */
extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to); extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to);

View File

@ -66,8 +66,8 @@ PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
const char *filename, /* decoded from the filesystem encoding */ const char *filename, /* decoded from the filesystem encoding */
const char* enc, const char* enc,
int start, int start,
char *ps1, const char *ps1,
char *ps2, const char *ps2,
PyCompilerFlags *flags, PyCompilerFlags *flags,
int *errcode, int *errcode,
PyArena *arena); PyArena *arena);
@ -76,8 +76,8 @@ PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject(
PyObject *filename, PyObject *filename,
const char* enc, const char* enc,
int start, int start,
char *ps1, const char *ps1,
char *ps2, const char *ps2,
PyCompilerFlags *flags, PyCompilerFlags *flags,
int *errcode, int *errcode,
PyArena *arena); PyArena *arena);

View File

@ -94,7 +94,7 @@ wchar_t *Py_DecodeLocale(const char* arg, size_t *size)
} }
/* Parser/pgenmain.c */ /* Parser/pgenmain.c */
grammar *getgrammar(char *filename) grammar *getgrammar(const char *filename)
{ {
grammar *g; grammar *g;
__coverity_tainted_data_sink__(filename); __coverity_tainted_data_sink__(filename);

View File

@ -3195,7 +3195,7 @@ _validate_paramflags(PyTypeObject *type, PyObject *paramflags)
} }
static int static int
_get_name(PyObject *obj, char **pname) _get_name(PyObject *obj, const char **pname)
{ {
#ifdef MS_WIN32 #ifdef MS_WIN32
if (PyLong_Check(obj)) { if (PyLong_Check(obj)) {
@ -3223,7 +3223,7 @@ _get_name(PyObject *obj, char **pname)
static PyObject * static PyObject *
PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds) PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
char *name; const char *name;
int (* address)(void); int (* address)(void);
PyObject *ftuple; PyObject *ftuple;
PyObject *dll; PyObject *dll;

View File

@ -77,7 +77,7 @@ PyTypeObject PyCThunk_Type = {
/**************************************************************/ /**************************************************************/
static void static void
PrintError(char *msg, ...) PrintError(const char *msg, ...)
{ {
char buf[512]; char buf[512];
PyObject *f = PySys_GetObject("stderr"); PyObject *f = PySys_GetObject("stderr");

View File

@ -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 * Raise a new exception 'exc_class', adding additional text to the original
* exception string. * exception string.
*/ */
void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...) void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
{ {
va_list vargs; va_list vargs;
PyObject *tp, *v, *tb, *s, *cls_str, *msg_str; PyObject *tp, *v, *tb, *s, *cls_str, *msg_str;

View File

@ -327,7 +327,7 @@ extern int
PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
Py_ssize_t index, Py_ssize_t size, char *ptr); 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 { struct basespec {
CDataObject *base; CDataObject *base;

View File

@ -56,7 +56,7 @@ static struct PyModuleDef _curses_panelmodule;
*/ */
static PyObject * static PyObject *
PyCursesCheckERR(int code, char *fname) PyCursesCheckERR(int code, const char *fname)
{ {
if (code != ERR) { if (code != ERR) {
Py_INCREF(Py_None); Py_INCREF(Py_None);

View File

@ -873,7 +873,7 @@ get_tzinfo_member(PyObject *self)
* this returns NULL. Else result is returned. * this returns NULL. Else result is returned.
*/ */
static PyObject * static PyObject *
call_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg) call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg)
{ {
PyObject *offset; PyObject *offset;

View File

@ -60,7 +60,7 @@ extern PyObject *_PyIncrementalNewlineDecoder_decode(
* Otherwise, the line ending is specified by readnl, a str object */ * Otherwise, the line ending is specified by readnl, a str object */
extern Py_ssize_t _PyIO_find_line_ending( extern Py_ssize_t _PyIO_find_line_ending(
int translated, int universal, PyObject *readnl, 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 /* Return 1 if an EnvironmentError with errno == EINTR is set (and then
clears the error indicator), 0 otherwise. clears the error indicator), 0 otherwise.

View File

@ -659,7 +659,7 @@ _bufferedreader_raw_read(buffered *self, char *start, Py_ssize_t len);
/* Sets the current error to BlockingIOError */ /* Sets the current error to BlockingIOError */
static void static void
_set_BlockingIOError(char *msg, Py_ssize_t written) _set_BlockingIOError(const char *msg, Py_ssize_t written)
{ {
PyObject *err; PyObject *err;
PyErr_Clear(); PyErr_Clear();

View File

@ -540,7 +540,7 @@ err_closed(void)
} }
static PyObject * static PyObject *
err_mode(char *action) err_mode(const char *action)
{ {
_PyIO_State *state = IO_STATE(); _PyIO_State *state = IO_STATE();
if (state != NULL) if (state != NULL)
@ -1043,7 +1043,7 @@ _io_FileIO_truncate_impl(fileio *self, PyObject *posobj)
} }
#endif /* HAVE_FTRUNCATE */ #endif /* HAVE_FTRUNCATE */
static char * static const char *
mode_string(fileio *self) mode_string(fileio *self)
{ {
if (self->created) { if (self->created) {

View File

@ -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, /* NOTE: `end` must point to the real end of the Py_UCS4 storage,
that is to the NUL character. Otherwise the function will produce that is to the NUL character. Otherwise the function will produce
incorrect results. */ incorrect results. */
static char * static const char *
find_control_char(int kind, char *s, char *end, Py_UCS4 ch) find_control_char(int kind, const char *s, const char *end, Py_UCS4 ch)
{ {
if (kind == PyUnicode_1BYTE_KIND) { if (kind == PyUnicode_1BYTE_KIND) {
assert(ch < 256); assert(ch < 256);
@ -1669,13 +1669,13 @@ find_control_char(int kind, char *s, char *end, Py_UCS4 ch)
Py_ssize_t Py_ssize_t
_PyIO_find_line_ending( _PyIO_find_line_ending(
int translated, int universal, PyObject *readnl, 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; Py_ssize_t len = ((char*)end - (char*)start)/kind;
if (translated) { if (translated) {
/* Newlines are already translated, only search for \n */ /* 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) if (pos != NULL)
return (pos - start)/kind + 1; return (pos - start)/kind + 1;
else { else {
@ -1687,7 +1687,7 @@ _PyIO_find_line_ending(
/* Universal newline search. Find any of \r, \r\n, \n /* Universal newline search. Find any of \r, \r\n, \n
* The decoder ensures that \r\n are not split in two pieces * The decoder ensures that \r\n are not split in two pieces
*/ */
char *s = start; const char *s = start;
for (;;) { for (;;) {
Py_UCS4 ch; Py_UCS4 ch;
/* Fast path for non-control chars. The loop always ends /* 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. */ /* Assume that readnl is an ASCII character. */
assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND); assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND);
if (readnl_len == 1) { 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) if (pos != NULL)
return (pos - start)/kind + 1; return (pos - start)/kind + 1;
*consumed = len; *consumed = len;
return -1; return -1;
} }
else { else {
char *s = start; const char *s = start;
char *e = end - (readnl_len - 1)*kind; const char *e = end - (readnl_len - 1)*kind;
char *pos; const char *pos;
if (e < s) if (e < s)
e = s; e = s;
while (s < e) { while (s < e) {
Py_ssize_t i; 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) if (pos == NULL || pos >= e)
break; break;
for (i = 1; i < readnl_len; i++) { for (i = 1; i < readnl_len; i++) {

View File

@ -112,7 +112,7 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc, PyObject *dct, Py_ssiz
static PyObject * static PyObject *
_encoded_const(PyObject *obj); _encoded_const(PyObject *obj);
static void 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 * static PyObject *
encoder_encode_string(PyEncoderObject *s, PyObject *obj); encoder_encode_string(PyEncoderObject *s, PyObject *obj);
static PyObject * static PyObject *
@ -323,7 +323,7 @@ escape_unicode(PyObject *pystr)
} }
static void 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 */ /* Use JSONDecodeError exception to raise a nice looking ValueError subclass */
static PyObject *JSONDecodeError = NULL; static PyObject *JSONDecodeError = NULL;

View File

@ -49,7 +49,7 @@ PyDoc_STRVAR(setlocale__doc__,
/* the grouping is terminated by either 0 or CHAR_MAX */ /* the grouping is terminated by either 0 or CHAR_MAX */
static PyObject* static PyObject*
copy_grouping(char* s) copy_grouping(const char* s)
{ {
int i; int i;
PyObject *result, *val = NULL; PyObject *result, *val = NULL;

View File

@ -2187,7 +2187,7 @@ error:
} }
static int 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]; char header[9];
Py_ssize_t len; Py_ssize_t len;

View File

@ -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. */ /* Convert ASCII to a positive int, no libc call. no overflow. -1 on error. */
static int static int
_pos_int_from_ascii(char *name) _pos_int_from_ascii(const char *name)
{ {
int num = 0; int num = 0;
while (*name >= '0' && *name <= '9') { while (*name >= '0' && *name <= '9') {

View File

@ -130,7 +130,7 @@ error:
} }
static int static int
set_proxy(PyObject* proxies, char* proto, CFDictionaryRef proxyDict, set_proxy(PyObject* proxies, const char* proto, CFDictionaryRef proxyDict,
CFStringRef enabledKey, CFStringRef enabledKey,
CFStringRef hostKey, CFStringRef portKey) CFStringRef hostKey, CFStringRef portKey)
{ {

View File

@ -714,7 +714,7 @@ _sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string,
} }
static PyObject* static PyObject*
call(char* module, char* function, PyObject* args) call(const char* module, const char* function, PyObject* args)
{ {
PyObject* name; PyObject* name;
PyObject* mod; PyObject* mod;

View File

@ -378,7 +378,7 @@ fail:
} }
static PyObject * 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; PyObject *type = PySSLErrorObject;
char *errstr = NULL; char *errstr = NULL;
@ -460,7 +460,7 @@ PySSL_SetError(PySSLSocket *obj, int ret, char *filename, int lineno)
} }
static PyObject * 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) if (errstr == NULL)
errcode = ERR_peek_last_error(); errcode = ERR_peek_last_error();

View File

@ -1189,7 +1189,7 @@ static formatdef lilendian_table[] = {
static const formatdef * static const formatdef *
whichtable(char **pfmt) whichtable(const char **pfmt)
{ {
const char *fmt = (*pfmt)++; /* May be backed out of later */ const char *fmt = (*pfmt)++; /* May be backed out of later */
switch (*fmt) { switch (*fmt) {
@ -1268,7 +1268,7 @@ prepare_s(PyStructObject *self)
fmt = PyBytes_AS_STRING(self->s_format); fmt = PyBytes_AS_STRING(self->s_format);
f = whichtable((char **)&fmt); f = whichtable(&fmt);
s = fmt; s = fmt;
size = 0; size = 0;
@ -1457,7 +1457,7 @@ s_dealloc(PyStructObject *s)
} }
static PyObject * static PyObject *
s_unpack_internal(PyStructObject *soself, char *startfrom) { s_unpack_internal(PyStructObject *soself, const char *startfrom) {
formatcode *code; formatcode *code;
Py_ssize_t i = 0; Py_ssize_t i = 0;
PyObject *result = PyTuple_New(soself->s_len); PyObject *result = PyTuple_New(soself->s_len);

View File

@ -61,7 +61,7 @@ Example_getattro(ExampleObject *self, PyObject *name)
} }
static int static int
Example_setattr(ExampleObject *self, char *name, PyObject *v) Example_setattr(ExampleObject *self, const char *name, PyObject *v)
{ {
if (self->x_attr == NULL) { if (self->x_attr == NULL) {
self->x_attr = PyDict_New(); self->x_attr = PyDict_New();

View File

@ -841,7 +841,7 @@ PyTclObject_dealloc(PyTclObject *self)
Py_DECREF(tp); Py_DECREF(tp);
} }
static char* static const char *
PyTclObject_TclString(PyObject *self) PyTclObject_TclString(PyObject *self)
{ {
return Tcl_GetString(((PyTclObject*)self)->value); return Tcl_GetString(((PyTclObject*)self)->value);
@ -1726,7 +1726,7 @@ static int
varname_converter(PyObject *in, void *_out) varname_converter(PyObject *in, void *_out)
{ {
char *s; char *s;
char **out = (char**)_out; const char **out = (const char**)_out;
if (PyBytes_Check(in)) { if (PyBytes_Check(in)) {
if (PyBytes_Size(in) > INT_MAX) { if (PyBytes_Size(in) > INT_MAX) {
PyErr_SetString(PyExc_OverflowError, "bytes object is too long"); 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 * static PyObject *
SetVar(PyObject *self, PyObject *args, int flags) SetVar(PyObject *self, PyObject *args, int flags)
{ {
char *name1, *name2; const char *name1, *name2;
PyObject *newValue; PyObject *newValue;
PyObject *res = NULL; PyObject *res = NULL;
Tcl_Obj *newval, *ok; Tcl_Obj *newval, *ok;
@ -1915,7 +1915,7 @@ Tkapp_GlobalSetVar(PyObject *self, PyObject *args)
static PyObject * static PyObject *
GetVar(PyObject *self, PyObject *args, int flags) GetVar(PyObject *self, PyObject *args, int flags)
{ {
char *name1, *name2=NULL; const char *name1, *name2=NULL;
PyObject *res = NULL; PyObject *res = NULL;
Tcl_Obj *tres; Tcl_Obj *tres;

View File

@ -675,7 +675,7 @@ _winapi_CreatePipe_impl(PyModuleDef *module, PyObject *pipe_attrs,
/* helpers for createprocess */ /* helpers for createprocess */
static unsigned long static unsigned long
getulong(PyObject* obj, char* name) getulong(PyObject* obj, const char* name)
{ {
PyObject* value; PyObject* value;
unsigned long ret; unsigned long ret;
@ -691,7 +691,7 @@ getulong(PyObject* obj, char* name)
} }
static HANDLE static HANDLE
gethandle(PyObject* obj, char* name) gethandle(PyObject* obj, const char* name)
{ {
PyObject* value; PyObject* value;
HANDLE ret; HANDLE ret;

View File

@ -256,7 +256,8 @@ static PyObject *
binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data) binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=5779f39b0b48459f input=7cafeaf73df63d1c]*/ /*[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; int leftbits = 0;
unsigned char this_ch; unsigned char this_ch;
unsigned int leftchar = 0; unsigned int leftchar = 0;
@ -342,7 +343,8 @@ static PyObject *
binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data) binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=181021b69bb9a414 input=00fdf458ce8b465b]*/ /*[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; int leftbits = 0;
unsigned char this_ch; unsigned char this_ch;
unsigned int leftchar = 0; unsigned int leftchar = 0;
@ -389,7 +391,7 @@ binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data)
static int 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 /* Finds & returns the (num+1)th
** valid character for base64, or -1 if none. ** valid character for base64, or -1 if none.
@ -426,7 +428,8 @@ static PyObject *
binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data) binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=3e351b702bed56d2 input=5872acf6e1cac243]*/ /*[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; int leftbits = 0;
unsigned char this_ch; unsigned char this_ch;
unsigned int leftchar = 0; unsigned int leftchar = 0;
@ -522,7 +525,8 @@ static PyObject *
binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline) binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline)
/*[clinic end generated code: output=19e1dd719a890b50 input=7b2ea6fa38d8924c]*/ /*[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; int leftbits = 0;
unsigned char this_ch; unsigned char this_ch;
unsigned int leftchar = 0; unsigned int leftchar = 0;
@ -589,7 +593,8 @@ static PyObject *
binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data) binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=60bcdbbd28b105cd input=0d914c680e0eed55]*/ /*[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; int leftbits = 0;
unsigned char this_ch; unsigned char this_ch;
unsigned int leftchar = 0; unsigned int leftchar = 0;
@ -667,7 +672,8 @@ static PyObject *
binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data) binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=0905da344dbf0648 input=e1f1712447a82b09]*/ /*[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; unsigned char ch;
Py_ssize_t in, inend, len; Py_ssize_t in, inend, len;
_PyBytesWriter writer; _PyBytesWriter writer;
@ -728,7 +734,8 @@ static PyObject *
binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data) binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=5a987810d5e3cdbb input=9596ebe019fe12ba]*/ /*[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; int leftbits = 0;
unsigned char this_ch; unsigned char this_ch;
unsigned int leftchar = 0; unsigned int leftchar = 0;
@ -782,7 +789,8 @@ static PyObject *
binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data) binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=f7afd89b789946ab input=54cdd49fc014402c]*/ /*[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; unsigned char in_byte, in_repeat;
Py_ssize_t in_len; Py_ssize_t in_len;
_PyBytesWriter writer; _PyBytesWriter writer;
@ -899,7 +907,7 @@ static unsigned int
binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc) binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
/*[clinic end generated code: output=167c2dac62625717 input=add8c53712ccceda]*/ /*[clinic end generated code: output=167c2dac62625717 input=add8c53712ccceda]*/
{ {
unsigned char *bin_data; const unsigned char *bin_data;
Py_ssize_t len; Py_ssize_t len;
crc &= 0xffff; crc &= 0xffff;
@ -1050,7 +1058,7 @@ binascii_crc32_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
#ifdef USE_ZLIB_CRC32 #ifdef USE_ZLIB_CRC32
/* This was taken from zlibmodule.c PyZlib_crc32 (but is PY_SSIZE_T_CLEAN) */ /* This was taken from zlibmodule.c PyZlib_crc32 (but is PY_SSIZE_T_CLEAN) */
{ {
Byte *buf; const Byte *buf;
Py_ssize_t len; Py_ssize_t len;
int signed_val; int signed_val;
@ -1061,7 +1069,7 @@ binascii_crc32_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
} }
#else /* USE_ZLIB_CRC32 */ #else /* USE_ZLIB_CRC32 */
{ /* By Jim Ahlstrom; All rights transferred to CNRI */ { /* By Jim Ahlstrom; All rights transferred to CNRI */
unsigned char *bin_data; const unsigned char *bin_data;
Py_ssize_t len; Py_ssize_t len;
unsigned int result; unsigned int result;
@ -1144,7 +1152,7 @@ static PyObject *
binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr) binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr)
/*[clinic end generated code: output=d61da452b5c6d290 input=9e1e7f2f94db24fd]*/ /*[clinic end generated code: output=d61da452b5c6d290 input=9e1e7f2f94db24fd]*/
{ {
char* argbuf; const char* argbuf;
Py_ssize_t arglen; Py_ssize_t arglen;
PyObject *retval; PyObject *retval;
char* retbuf; char* retbuf;
@ -1232,7 +1240,8 @@ binascii_a2b_qp_impl(PyModuleDef *module, Py_buffer *data, int header)
{ {
Py_ssize_t in, out; Py_ssize_t in, out;
char ch; char ch;
unsigned char *ascii_data, *odata; const unsigned char *ascii_data;
unsigned char *odata;
Py_ssize_t datalen = 0; Py_ssize_t datalen = 0;
PyObject *rv; 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]*/ /*[clinic end generated code: output=a87ca9ccb94e2a9f input=7f2a9aaa008e92b2]*/
{ {
Py_ssize_t in, out; Py_ssize_t in, out;
unsigned char *databuf, *odata; const unsigned char *databuf;
unsigned char *odata;
Py_ssize_t datalen = 0, odatalen = 0; Py_ssize_t datalen = 0, odatalen = 0;
PyObject *rv; PyObject *rv;
unsigned int linelen = 0; unsigned int linelen = 0;
unsigned char ch; unsigned char ch;
int crlf = 0; int crlf = 0;
unsigned char *p; const unsigned char *p;
databuf = data->buf; databuf = data->buf;
datalen = data->len; 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 /* XXX: this function has the side effect of converting all of
* the end of lines to be the same depending on this detection * the end of lines to be the same depending on this detection
* here */ * here */
p = (unsigned char *) memchr(databuf, '\n', datalen); p = (const unsigned char *) memchr(databuf, '\n', datalen);
if ((p != NULL) && (p > databuf) && (*(p-1) == '\r')) if ((p != NULL) && (p > databuf) && (*(p-1) == '\r'))
crlf = 1; crlf = 1;

View File

@ -738,7 +738,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old)
} }
static void static void
debug_cycle(char *msg, PyObject *op) debug_cycle(const char *msg, PyObject *op)
{ {
PySys_FormatStderr("gc: %s <%s %p>\n", PySys_FormatStderr("gc: %s <%s %p>\n",
msg, Py_TYPE(op)->tp_name, op); msg, Py_TYPE(op)->tp_name, op);

View File

@ -198,7 +198,7 @@ if (pai->ai_flags & AI_CANONNAME) {\
#define ERR(err) { error = (err); goto bad; } #define ERR(err) { error = (err); goto bad; }
char * const char *
gai_strerror(int ecode) gai_strerror(int ecode)
{ {
if (ecode < 0 || ecode > EAI_MAX) if (ecode < 0 || ecode > EAI_MAX)

View File

@ -103,7 +103,7 @@ PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n\
"; ";
static int static int
usage(int exitcode, wchar_t* program) usage(int exitcode, const wchar_t* program)
{ {
FILE *f = exitcode ? stderr : stdout; FILE *f = exitcode ? stderr : stdout;

View File

@ -876,7 +876,7 @@ math_1_to_int(PyObject *arg, double (*func) (double), int can_overflow)
} }
static PyObject * 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; PyObject *ox, *oy;
double x, y, r; double x, y, r;
@ -1673,7 +1673,7 @@ PyDoc_STRVAR(math_modf_doc,
in that int is larger than PY_SSIZE_T_MAX. */ in that int is larger than PY_SSIZE_T_MAX. */
static PyObject* 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 it is int, do it ourselves. */
if (PyLong_Check(arg)) { if (PyLong_Check(arg)) {

View File

@ -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. * Sets the error string for an exception of type ParserError.
* *
*/ */
static void static void
err_string(char *message) err_string(const char *message)
{ {
PyErr_SetString(parser_error, message); PyErr_SetString(parser_error, message);
} }
@ -597,7 +597,7 @@ err_string(char *message)
* *
*/ */
static PyObject* 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; char* string = 0;
PyObject* res = 0; PyObject* res = 0;
@ -984,7 +984,7 @@ build_node_tree(PyObject *tuple)
/* /*
* Validation routines used within the validation section: * 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_ampersand(ch) validate_terminal(ch, AMPER, "&")
#define validate_circumflex(ch) validate_terminal(ch, CIRCUMFLEX, "^") #define validate_circumflex(ch) validate_terminal(ch, CIRCUMFLEX, "^")
@ -1082,7 +1082,7 @@ validate_numnodes(node *n, int num, const char *const name)
static int 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) int res = (validate_ntype(terminal, type)
&& ((string == 0) || (strcmp(string, STR(terminal)) == 0))); && ((string == 0) || (strcmp(string, STR(terminal)) == 0)));

View File

@ -949,7 +949,8 @@ path_converter(PyObject *o, void *p) {
} }
static void 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, PyErr_Format(PyExc_NotImplementedError,
"%s%s%s unavailable on this platform", "%s%s%s unavailable on this platform",
(function_name != NULL) ? function_name : "", (function_name != NULL) ? function_name : "",
@ -972,7 +973,8 @@ dir_fd_unavailable(PyObject *o, void *p)
} }
static int static int
fd_specified(char *function_name, int fd) { fd_specified(const char *function_name, int fd)
{
if (fd == -1) if (fd == -1)
return 0; return 0;
@ -981,7 +983,8 @@ fd_specified(char *function_name, int fd) {
} }
static int static int
follow_symlinks_specified(char *function_name, int follow_symlinks) { follow_symlinks_specified(const char *function_name, int follow_symlinks)
{
if (follow_symlinks) if (follow_symlinks)
return 0; return 0;
@ -990,7 +993,8 @@ follow_symlinks_specified(char *function_name, int follow_symlinks) {
} }
static int 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)) { if (!path->narrow && !path->wide && (dir_fd != DEFAULT_DIR_FD)) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%s: can't specify dir_fd without matching path", "%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 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)) { if ((dir_fd != DEFAULT_DIR_FD) && (fd != -1)) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%s: can't specify both dir_fd and fd", "%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 static int
fd_and_follow_symlinks_invalid(char *function_name, int fd, fd_and_follow_symlinks_invalid(const char *function_name, int fd,
int follow_symlinks) { int follow_symlinks)
{
if ((fd > 0) && (!follow_symlinks)) { if ((fd > 0) && (!follow_symlinks)) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%s: cannot use fd and follow_symlinks together", "%s: cannot use fd and follow_symlinks together",
@ -1024,8 +1030,9 @@ fd_and_follow_symlinks_invalid(char *function_name, int fd,
} }
static int static int
dir_fd_and_follow_symlinks_invalid(char *function_name, int dir_fd, dir_fd_and_follow_symlinks_invalid(const char *function_name, int dir_fd,
int follow_symlinks) { int follow_symlinks)
{
if ((dir_fd != DEFAULT_DIR_FD) && (!follow_symlinks)) { if ((dir_fd != DEFAULT_DIR_FD) && (!follow_symlinks)) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"%s: cannot use dir_fd and follow_symlinks together", "%s: cannot use dir_fd and follow_symlinks together",
@ -1220,7 +1227,7 @@ posix_error(void)
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
static PyObject * 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. /* XXX We should pass the function name along in the future.
(winreg.c also wants to pass the function name.) (winreg.c also wants to pass the function name.)
@ -1235,7 +1242,7 @@ win32_error(char* function, const char* filename)
} }
static PyObject * 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' */ /* XXX - see win32_error for comments on 'function' */
errno = GetLastError(); errno = GetLastError();
@ -2100,7 +2107,7 @@ _pystat_fromstructstat(STRUCT_STAT *st)
static PyObject * 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) int dir_fd, int follow_symlinks)
{ {
STRUCT_STAT st; STRUCT_STAT st;
@ -4561,7 +4568,7 @@ typedef struct {
#if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT) #if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)
static int 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 #ifdef HAVE_UTIMENSAT
int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW; int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW;
@ -4610,7 +4617,7 @@ utime_fd(utime_t *ut, int fd)
#ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS #ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS
static int static int
utime_nofollow_symlinks(utime_t *ut, char *path) utime_nofollow_symlinks(utime_t *ut, const char *path)
{ {
#ifdef HAVE_UTIMENSAT #ifdef HAVE_UTIMENSAT
UTIME_TO_TIMESPEC; UTIME_TO_TIMESPEC;
@ -4626,7 +4633,7 @@ utime_nofollow_symlinks(utime_t *ut, char *path)
#ifndef MS_WINDOWS #ifndef MS_WINDOWS
static int static int
utime_default(utime_t *ut, char *path) utime_default(utime_t *ut, const char *path)
{ {
#ifdef HAVE_UTIMENSAT #ifdef HAVE_UTIMENSAT
UTIME_TO_TIMESPEC; 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 */ /* Return True if the path at src relative to dest is a directory */
static int static int
_check_dirA(char *src, char *dest) _check_dirA(const char *src, char *dest)
{ {
WIN32_FILE_ATTRIBUTE_DATA src_info; WIN32_FILE_ATTRIBUTE_DATA src_info;
char dest_parent[MAX_PATH]; char dest_parent[MAX_PATH];
@ -11835,7 +11842,7 @@ error:
#else /* POSIX */ #else /* POSIX */
static char * 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 path_len;
Py_ssize_t size; Py_ssize_t size;
@ -11867,7 +11874,7 @@ join_path_filename(char *path_narrow, char* filename, Py_ssize_t filename_len)
} }
static PyObject * 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 ino_t d_ino
#ifdef HAVE_DIRENT_D_TYPE #ifdef HAVE_DIRENT_D_TYPE
, unsigned char d_type , unsigned char d_type

View File

@ -91,7 +91,7 @@ static struct HandlerInfo handler_info[64];
* false on an exception. * false on an exception.
*/ */
static int 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); PyObject *v = PyLong_FromLong(value);
@ -218,7 +218,7 @@ flag_error(xmlparseobject *self)
} }
static PyObject* 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) xmlparseobject *self)
{ {
PyObject *res; PyObject *res;
@ -766,7 +766,7 @@ readinst(char *buf, int buf_size, PyObject *meth)
{ {
PyObject *str; PyObject *str;
Py_ssize_t len; Py_ssize_t len;
char *ptr; const char *ptr;
str = PyObject_CallFunction(meth, "n", buf_size); str = PyObject_CallFunction(meth, "n", buf_size);
if (str == NULL) if (str == NULL)

View File

@ -904,7 +904,7 @@ static PyThread_type_lock netdb_lock;
an error occurred; then an exception is raised. */ an error occurred; then an exception is raised. */
static int 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; struct addrinfo hints, *res;
int error; int error;
@ -1085,7 +1085,7 @@ makeipaddr(struct sockaddr *addr, int addrlen)
an error occurred. */ an error occurred. */
static int static int
setbdaddr(char *name, bdaddr_t *bdaddr) setbdaddr(const char *name, bdaddr_t *bdaddr)
{ {
unsigned int b0, b1, b2, b3, b4, b5; unsigned int b0, b1, b2, b3, b4, b5;
char ch; char ch;

View File

@ -311,7 +311,7 @@ tmtotuple(struct tm *p)
Returns non-zero on success (parallels PyArg_ParseTuple). Returns non-zero on success (parallels PyArg_ParseTuple).
*/ */
static int 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; PyObject *ot = NULL;
time_t whent; time_t whent;

View File

@ -89,7 +89,7 @@ Xxo_getattro(XxoObject *self, PyObject *name)
} }
static int static int
Xxo_setattr(XxoObject *self, char *name, PyObject *v) Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
{ {
if (self->x_attr == NULL) { if (self->x_attr == NULL) {
self->x_attr = PyDict_New(); self->x_attr = PyDict_New();

View File

@ -76,7 +76,7 @@ Xxo_getattro(XxoObject *self, PyObject *name)
} }
static int static int
Xxo_setattr(XxoObject *self, char *name, PyObject *v) Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
{ {
if (self->x_attr == NULL) { if (self->x_attr == NULL) {
self->x_attr = PyDict_New(); self->x_attr = PyDict_New();

View File

@ -815,7 +815,7 @@ static PyTypeObject ZipImporter_Type = {
4 bytes, encoded as little endian. This partially reimplements 4 bytes, encoded as little endian. This partially reimplements
marshal.c:r_long() */ marshal.c:r_long() */
static long static long
get_long(unsigned char *buf) { get_long(const unsigned char *buf) {
long x; long x;
x = buf[0]; x = buf[0];
x |= (long)buf[1] << 8; x |= (long)buf[1] << 8;

View File

@ -53,7 +53,7 @@ typedef struct
} compobject; } compobject;
static void 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; const char *zmsg = Z_NULL;
/* In case of a version mismatch, zst.msg won't be initialized. /* In case of a version mismatch, zst.msg won't be initialized.

View File

@ -2576,8 +2576,8 @@ bytearray_remove_impl(PyByteArrayObject *self, int value)
/* XXX These two helpers could be optimized if argsize == 1 */ /* XXX These two helpers could be optimized if argsize == 1 */
static Py_ssize_t static Py_ssize_t
lstrip_helper(char *myptr, Py_ssize_t mysize, lstrip_helper(const char *myptr, Py_ssize_t mysize,
void *argptr, Py_ssize_t argsize) const void *argptr, Py_ssize_t argsize)
{ {
Py_ssize_t i = 0; Py_ssize_t i = 0;
while (i < mysize && memchr(argptr, (unsigned char) myptr[i], argsize)) while (i < mysize && memchr(argptr, (unsigned char) myptr[i], argsize))
@ -2586,8 +2586,8 @@ lstrip_helper(char *myptr, Py_ssize_t mysize,
} }
static Py_ssize_t static Py_ssize_t
rstrip_helper(char *myptr, Py_ssize_t mysize, rstrip_helper(const char *myptr, Py_ssize_t mysize,
void *argptr, Py_ssize_t argsize) const void *argptr, Py_ssize_t argsize)
{ {
Py_ssize_t i = mysize - 1; Py_ssize_t i = mysize - 1;
while (i >= 0 && memchr(argptr, (unsigned char) myptr[i], argsize)) while (i >= 0 && memchr(argptr, (unsigned char) myptr[i], argsize))

View File

@ -277,7 +277,7 @@ Return a titlecased version of B, i.e. ASCII words start with uppercase\n\
characters, all remaining cased characters have lowercase."); characters, all remaining cased characters have lowercase.");
void void
_Py_bytes_title(char *result, char *s, Py_ssize_t len) _Py_bytes_title(char *result, const char *s, Py_ssize_t len)
{ {
Py_ssize_t i; Py_ssize_t i;
int previous_is_cased = 0; int previous_is_cased = 0;
@ -306,7 +306,7 @@ Return a copy of B with only its first character capitalized (ASCII)\n\
and the rest lower-cased."); and the rest lower-cased.");
void void
_Py_bytes_capitalize(char *result, char *s, Py_ssize_t len) _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len)
{ {
Py_ssize_t i; Py_ssize_t i;
@ -336,7 +336,7 @@ Return a copy of B with uppercase ASCII characters converted\n\
to lowercase ASCII and vice versa."); to lowercase ASCII and vice versa.");
void void
_Py_bytes_swapcase(char *result, char *s, Py_ssize_t len) _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len)
{ {
Py_ssize_t i; Py_ssize_t i;

View File

@ -308,7 +308,7 @@ PyBytes_FromFormatV(const char *format, va_list vargs)
{ {
Py_ssize_t i; Py_ssize_t i;
p = va_arg(vargs, char*); p = va_arg(vargs, const char*);
i = strlen(p); i = strlen(p);
if (prec > 0 && i > prec) if (prec > 0 && i > prec)
i = prec; i = prec;

View File

@ -22,7 +22,7 @@ descr_name(PyDescrObject *descr)
} }
static PyObject * static PyObject *
descr_repr(PyDescrObject *descr, char *format) descr_repr(PyDescrObject *descr, const char *format)
{ {
PyObject *name = NULL; PyObject *name = NULL;
if (descr->d_name != NULL && PyUnicode_Check(descr->d_name)) if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))

View File

@ -1925,7 +1925,7 @@ dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value)
} }
static int static int
dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methname) dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, const char *methname)
{ {
PyObject *arg = NULL; PyObject *arg = NULL;
int result = 0; int result = 0;

View File

@ -1133,7 +1133,7 @@ get_native_fmtchar(char *result, const char *fmt)
return -1; return -1;
} }
Py_LOCAL_INLINE(char *) Py_LOCAL_INLINE(const char *)
get_native_fmtstr(const char *fmt) get_native_fmtstr(const char *fmt)
{ {
int at = 0; int at = 0;
@ -1221,7 +1221,7 @@ cast_to_1D(PyMemoryViewObject *mv, PyObject *format)
goto out; goto out;
} }
view->format = get_native_fmtstr(PyBytes_AS_STRING(asciifmt)); view->format = (char *)get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
if (view->format == NULL) { if (view->format == NULL) {
/* NOT_REACHED: get_native_fmtchar() already validates the format. */ /* NOT_REACHED: get_native_fmtchar() already validates the format. */
PyErr_SetString(PyExc_RuntimeError, PyErr_SetString(PyExc_RuntimeError,

View File

@ -564,7 +564,7 @@ type_get_bases(PyTypeObject *type, void *context)
static PyTypeObject *best_base(PyObject *); static PyTypeObject *best_base(PyObject *);
static int mro_internal(PyTypeObject *, PyObject **); static int mro_internal(PyTypeObject *, PyObject **);
Py_LOCAL_INLINE(int) type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *); Py_LOCAL_INLINE(int) type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *);
static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, char *); static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *);
static int add_subclass(PyTypeObject*, PyTypeObject*); static int add_subclass(PyTypeObject*, PyTypeObject*);
static int add_all_subclasses(PyTypeObject *type, PyObject *bases); static int add_all_subclasses(PyTypeObject *type, PyObject *bases);
static void remove_subclass(PyTypeObject *, PyTypeObject *); static void remove_subclass(PyTypeObject *, PyTypeObject *);
@ -1435,7 +1435,7 @@ _PyObject_LookupSpecial(PyObject *self, _Py_Identifier *attrid)
as lookup_method to cache the interned name string object. */ as lookup_method to cache the interned name string object. */
static PyObject * static PyObject *
call_method(PyObject *o, _Py_Identifier *nameid, char *format, ...) call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
{ {
va_list va; va_list va;
PyObject *args, *func = 0, *retval; PyObject *args, *func = 0, *retval;
@ -1471,7 +1471,7 @@ call_method(PyObject *o, _Py_Identifier *nameid, char *format, ...)
/* Clone of call_method() that returns NotImplemented when the lookup fails. */ /* Clone of call_method() that returns NotImplemented when the lookup fails. */
static PyObject * static PyObject *
call_maybe(PyObject *o, _Py_Identifier *nameid, char *format, ...) call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
{ {
va_list va; va_list va;
PyObject *args, *func = 0, *retval; PyObject *args, *func = 0, *retval;
@ -3609,7 +3609,7 @@ same_slots_added(PyTypeObject *a, PyTypeObject *b)
} }
static int static int
compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, char* attr) compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, const char* attr)
{ {
PyTypeObject *newbase, *oldbase; PyTypeObject *newbase, *oldbase;
@ -5348,7 +5348,7 @@ wrap_delitem(PyObject *self, PyObject *args, void *wrapped)
/* Helper to check for object.__setattr__ or __delattr__ applied to a type. /* Helper to check for object.__setattr__ or __delattr__ applied to a type.
This is called the Carlo Verre hack after its discoverer. */ This is called the Carlo Verre hack after its discoverer. */
static int static int
hackcheck(PyObject *self, setattrofunc func, char *what) hackcheck(PyObject *self, setattrofunc func, const char *what)
{ {
PyTypeObject *type = Py_TYPE(self); PyTypeObject *type = Py_TYPE(self);
while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE) while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE)

View File

@ -6986,7 +6986,7 @@ PyUnicode_AsASCIIString(PyObject *unicode)
# define WC_ERR_INVALID_CHARS 0x0080 # define WC_ERR_INVALID_CHARS 0x0080
#endif #endif
static char* static const char*
code_page_name(UINT code_page, PyObject **obj) code_page_name(UINT code_page, PyObject **obj)
{ {
*obj = NULL; *obj = NULL;
@ -7094,7 +7094,7 @@ decode_code_page_errors(UINT code_page,
PyObject *errorHandler = NULL; PyObject *errorHandler = NULL;
PyObject *exc = NULL; PyObject *exc = NULL;
PyObject *encoding_obj = NULL; PyObject *encoding_obj = NULL;
char *encoding; const char *encoding;
DWORD err; DWORD err;
int ret = -1; int ret = -1;
@ -7438,7 +7438,7 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes,
PyObject *errorHandler = NULL; PyObject *errorHandler = NULL;
PyObject *exc = NULL; PyObject *exc = NULL;
PyObject *encoding_obj = NULL; PyObject *encoding_obj = NULL;
char *encoding; const char *encoding;
Py_ssize_t newpos, newoutsize; Py_ssize_t newpos, newoutsize;
PyObject *rep; PyObject *rep;
int ret = -1; int ret = -1;

View File

@ -265,7 +265,7 @@ insert_head(PyWeakReference *newref, PyWeakReference **list)
} }
static int static int
parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs, parse_weakref_init_args(const char *funcname, PyObject *args, PyObject *kwargs,
PyObject **obp, PyObject **callbackp) PyObject **obp, PyObject **callbackp)
{ {
/* XXX Should check that kwargs == NULL or is empty. */ /* XXX Should check that kwargs == NULL or is empty. */

View File

@ -379,7 +379,7 @@ typedef struct _ss_dfa {
/* Forward */ /* Forward */
static void printssdfa(int xx_nstates, ss_state *xx_state, int nbits, static void printssdfa(int xx_nstates, ss_state *xx_state, int nbits,
labellist *ll, char *msg); labellist *ll, const char *msg);
static void simplify(int xx_nstates, ss_state *xx_state); static void simplify(int xx_nstates, ss_state *xx_state);
static void convert(dfa *d, int xx_nstates, ss_state *xx_state); static void convert(dfa *d, int xx_nstates, ss_state *xx_state);
@ -494,7 +494,7 @@ makedfa(nfagrammar *gr, nfa *nf, dfa *d)
static void static void
printssdfa(int xx_nstates, ss_state *xx_state, int nbits, printssdfa(int xx_nstates, ss_state *xx_state, int nbits,
labellist *ll, char *msg) labellist *ll, const char *msg)
{ {
int i, ibit, iarc; int i, ibit, iarc;
ss_state *yy; ss_state *yy;

View File

@ -27,7 +27,7 @@ int Py_VerboseFlag;
int Py_IgnoreEnvironmentFlag; int Py_IgnoreEnvironmentFlag;
/* Forward */ /* Forward */
grammar *getgrammar(char *filename); grammar *getgrammar(const char *filename);
void Py_Exit(int) _Py_NO_RETURN; void Py_Exit(int) _Py_NO_RETURN;
@ -76,7 +76,7 @@ main(int argc, char **argv)
} }
grammar * grammar *
getgrammar(char *filename) getgrammar(const char *filename)
{ {
FILE *fp; FILE *fp;
node *n; node *n;

View File

@ -202,8 +202,8 @@ error_ret(struct tok_state *tok) /* XXX */
} }
static char * static const char *
get_normal_name(char *s) /* for utf-8 and latin-1 */ get_normal_name(const char *s) /* for utf-8 and latin-1 */
{ {
char buf[13]; char buf[13];
int i; int i;
@ -264,7 +264,7 @@ get_coding_spec(const char *s, char **spec, Py_ssize_t size, struct tok_state *t
if (begin < t) { if (begin < t) {
char* r = new_string(begin, t - begin, tok); char* r = new_string(begin, t - begin, tok);
char* q; const char* q;
if (!r) if (!r)
return 0; return 0;
q = get_normal_name(r); q = get_normal_name(r);

View File

@ -921,7 +921,7 @@ PyErr_WarnEx(PyObject *category, const char *text, Py_ssize_t stack_level)
#undef PyErr_Warn #undef PyErr_Warn
PyAPI_FUNC(int) PyAPI_FUNC(int)
PyErr_Warn(PyObject *category, char *text) PyErr_Warn(PyObject *category, const char *text)
{ {
return PyErr_WarnEx(category, text, 1); return PyErr_WarnEx(category, text, 1);
} }

View File

@ -125,7 +125,7 @@ static PyObject * load_args(PyObject ***, int);
#ifdef LLTRACE #ifdef LLTRACE
static int lltrace; static int lltrace;
static int prtrace(PyObject *, char *); static int prtrace(PyObject *, const char *);
#endif #endif
static int call_trace(Py_tracefunc, PyObject *, static int call_trace(Py_tracefunc, PyObject *,
PyThreadState *, PyFrameObject *, PyThreadState *, PyFrameObject *,
@ -4308,7 +4308,7 @@ Error:
#ifdef LLTRACE #ifdef LLTRACE
static int static int
prtrace(PyObject *v, char *str) prtrace(PyObject *v, const char *str)
{ {
printf("%s ", str); printf("%s ", str);
if (PyObject_Print(v, stdout, 0) != 0) if (PyObject_Print(v, stdout, 0) != 0)

View File

@ -2315,7 +2315,7 @@ rv_alloc(int i)
} }
static char * static char *
nrv_alloc(char *s, char **rve, int n) nrv_alloc(const char *s, char **rve, int n)
{ {
char *rv, *t; char *rv, *t;

View File

@ -41,7 +41,7 @@ const char *_PyImport_DynLoadFiletab[] = {
/* Case insensitive string compare, to avoid any dependencies on particular /* Case insensitive string compare, to avoid any dependencies on particular
C RTL implementations */ C RTL implementations */
static int strcasecmp (char *string1, char *string2) static int strcasecmp (const char *string1, const char *string2)
{ {
int first, second; int first, second;

View File

@ -20,12 +20,12 @@ int PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
#ifdef HAVE_DECLSPEC_DLL #ifdef HAVE_DECLSPEC_DLL
/* Export functions */ /* Export functions */
PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, char *, ...); PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, char *, ...); PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *, PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, ...); const char *, char **, ...);
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, char *, va_list); PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *, PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, va_list); const char *, char **, va_list);
#endif #endif
@ -56,18 +56,18 @@ typedef struct {
/* Forward */ /* Forward */
static int vgetargs1(PyObject *, const char *, va_list *, int); static int vgetargs1(PyObject *, const char *, va_list *, int);
static void seterror(Py_ssize_t, const char *, int *, const char *, const char *); static void seterror(Py_ssize_t, const char *, int *, const char *, const char *);
static char *convertitem(PyObject *, const char **, va_list *, int, int *, static const char *convertitem(PyObject *, const char **, va_list *, int, int *,
char *, size_t, freelist_t *); char *, size_t, freelist_t *);
static char *converttuple(PyObject *, const char **, va_list *, int, static const char *converttuple(PyObject *, const char **, va_list *, int,
int *, char *, size_t, int, freelist_t *); int *, char *, size_t, int, freelist_t *);
static char *convertsimple(PyObject *, const char **, va_list *, int, char *, static const char *convertsimple(PyObject *, const char **, va_list *, int,
size_t, freelist_t *); char *, size_t, freelist_t *);
static Py_ssize_t convertbuffer(PyObject *, void **p, char **); static Py_ssize_t convertbuffer(PyObject *, void **p, const char **);
static int getbuffer(PyObject *, Py_buffer *, char**); static int getbuffer(PyObject *, Py_buffer *, const char**);
static int vgetargskeywords(PyObject *, PyObject *, static int vgetargskeywords(PyObject *, PyObject *,
const char *, char **, va_list *, int); const char *, char **, va_list *, int);
static char *skipitem(const char **, va_list *, int); static const char *skipitem(const char **, va_list *, int);
int int
PyArg_Parse(PyObject *args, const char *format, ...) PyArg_Parse(PyObject *args, const char *format, ...)
@ -82,7 +82,7 @@ PyArg_Parse(PyObject *args, const char *format, ...)
} }
int int
_PyArg_Parse_SizeT(PyObject *args, char *format, ...) _PyArg_Parse_SizeT(PyObject *args, const char *format, ...)
{ {
int retval; int retval;
va_list va; va_list va;
@ -107,7 +107,7 @@ PyArg_ParseTuple(PyObject *args, const char *format, ...)
} }
int int
_PyArg_ParseTuple_SizeT(PyObject *args, char *format, ...) _PyArg_ParseTuple_SizeT(PyObject *args, const char *format, ...)
{ {
int retval; int retval;
va_list va; va_list va;
@ -130,7 +130,7 @@ PyArg_VaParse(PyObject *args, const char *format, va_list va)
} }
int int
_PyArg_VaParse_SizeT(PyObject *args, char *format, va_list va) _PyArg_VaParse_SizeT(PyObject *args, const char *format, va_list va)
{ {
va_list lva; va_list lva;
@ -208,7 +208,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
int endfmt = 0; int endfmt = 0;
const char *formatsave = format; const char *formatsave = format;
Py_ssize_t i, len; Py_ssize_t i, len;
char *msg; const char *msg;
int compat = flags & FLAG_COMPAT; int compat = flags & FLAG_COMPAT;
freelistentry_t static_entries[STATIC_FREELIST_ENTRIES]; freelistentry_t static_entries[STATIC_FREELIST_ENTRIES];
freelist_t freelist; freelist_t freelist;
@ -416,7 +416,7 @@ seterror(Py_ssize_t iarg, const char *msg, int *levels, const char *fname,
and msgbuf is returned. and msgbuf is returned.
*/ */
static char * static const char *
converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags, converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
int *levels, char *msgbuf, size_t bufsize, int toplevel, int *levels, char *msgbuf, size_t bufsize, int toplevel,
freelist_t *freelist) freelist_t *freelist)
@ -474,7 +474,7 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
format = *p_format; format = *p_format;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
char *msg; const char *msg;
PyObject *item; PyObject *item;
item = PySequence_GetItem(arg, i); item = PySequence_GetItem(arg, i);
if (item == NULL) { if (item == NULL) {
@ -501,11 +501,11 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
/* Convert a single item. */ /* Convert a single item. */
static char * static const char *
convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags, convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
int *levels, char *msgbuf, size_t bufsize, freelist_t *freelist) int *levels, char *msgbuf, size_t bufsize, freelist_t *freelist)
{ {
char *msg; const char *msg;
const char *format = *p_format; const char *format = *p_format;
if (*format == '(' /* ')' */) { if (*format == '(' /* ')' */) {
@ -530,7 +530,7 @@ convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
/* Format an error message generated by convertsimple(). */ /* Format an error message generated by convertsimple(). */
static char * static const char *
converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize) converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize)
{ {
assert(expected != NULL); assert(expected != NULL);
@ -566,7 +566,7 @@ float_argument_error(PyObject *arg)
When you add new format codes, please don't forget poor skipitem() below. When you add new format codes, please don't forget poor skipitem() below.
*/ */
static char * static const char *
convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
char *msgbuf, size_t bufsize, freelist_t *freelist) char *msgbuf, size_t bufsize, freelist_t *freelist)
{ {
@ -851,7 +851,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case 'y': {/* any bytes-like object */ case 'y': {/* any bytes-like object */
void **p = (void **)va_arg(*p_va, char **); void **p = (void **)va_arg(*p_va, char **);
char *buf; const char *buf;
Py_ssize_t count; Py_ssize_t count;
if (*format == '*') { if (*format == '*') {
if (getbuffer(arg, (Py_buffer*)p, &buf) < 0) if (getbuffer(arg, (Py_buffer*)p, &buf) < 0)
@ -898,7 +898,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
PyBuffer_FillInfo(p, arg, sarg, len, 1, 0); PyBuffer_FillInfo(p, arg, sarg, len, 1, 0);
} }
else { /* any bytes-like object */ else { /* any bytes-like object */
char *buf; const char *buf;
if (getbuffer(arg, p, &buf) < 0) if (getbuffer(arg, p, &buf) < 0)
return converterr(buf, arg, msgbuf, bufsize); return converterr(buf, arg, msgbuf, bufsize);
} }
@ -928,7 +928,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
} }
else { /* read-only bytes-like object */ else { /* read-only bytes-like object */
/* XXX Really? */ /* XXX Really? */
char *buf; const char *buf;
Py_ssize_t count = convertbuffer(arg, p, &buf); Py_ssize_t count = convertbuffer(arg, p, &buf);
if (count < 0) if (count < 0)
return converterr(buf, arg, msgbuf, bufsize); return converterr(buf, arg, msgbuf, bufsize);
@ -1275,7 +1275,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
} }
static Py_ssize_t static Py_ssize_t
convertbuffer(PyObject *arg, void **p, char **errmsg) convertbuffer(PyObject *arg, void **p, const char **errmsg)
{ {
PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer; PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer;
Py_ssize_t count; Py_ssize_t count;
@ -1297,7 +1297,7 @@ convertbuffer(PyObject *arg, void **p, char **errmsg)
} }
static int static int
getbuffer(PyObject *arg, Py_buffer *view, char **errmsg) getbuffer(PyObject *arg, Py_buffer *view, const char **errmsg)
{ {
if (PyObject_GetBuffer(arg, view, PyBUF_SIMPLE) != 0) { if (PyObject_GetBuffer(arg, view, PyBUF_SIMPLE) != 0) {
*errmsg = "bytes-like object"; *errmsg = "bytes-like object";
@ -1629,7 +1629,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
} }
static char * static const char *
skipitem(const char **p_format, va_list *p_va, int flags) skipitem(const char **p_format, va_list *p_va, int flags)
{ {
const char *format = *p_format; const char *format = *p_format;
@ -1722,7 +1722,7 @@ skipitem(const char **p_format, va_list *p_va, int flags)
case '(': /* bypass tuple, not handled at all previously */ case '(': /* bypass tuple, not handled at all previously */
{ {
char *msg; const char *msg;
for (;;) { for (;;) {
if (*format==')') if (*format==')')
break; break;

View File

@ -643,7 +643,7 @@ typedef struct {
PyObject *refs; /* a list */ PyObject *refs; /* a list */
} RFILE; } RFILE;
static char * static const char *
r_string(Py_ssize_t n, RFILE *p) r_string(Py_ssize_t n, RFILE *p)
{ {
Py_ssize_t read = -1; Py_ssize_t read = -1;
@ -729,7 +729,7 @@ r_byte(RFILE *p)
c = getc(p->fp); c = getc(p->fp);
} }
else { else {
char *ptr = r_string(1, p); const char *ptr = r_string(1, p);
if (ptr != NULL) if (ptr != NULL)
c = *(unsigned char *) ptr; c = *(unsigned char *) ptr;
} }
@ -740,9 +740,9 @@ static int
r_short(RFILE *p) r_short(RFILE *p)
{ {
short x = -1; short x = -1;
unsigned char *buffer; const unsigned char *buffer;
buffer = (unsigned char *) r_string(2, p); buffer = (const unsigned char *) r_string(2, p);
if (buffer != NULL) { if (buffer != NULL) {
x = buffer[0]; x = buffer[0];
x |= buffer[1] << 8; x |= buffer[1] << 8;
@ -756,9 +756,9 @@ static long
r_long(RFILE *p) r_long(RFILE *p)
{ {
long x = -1; long x = -1;
unsigned char *buffer; const unsigned char *buffer;
buffer = (unsigned char *) r_string(4, p); buffer = (const unsigned char *) r_string(4, p);
if (buffer != NULL) { if (buffer != NULL) {
x = buffer[0]; x = buffer[0];
x |= (long)buffer[1] << 8; x |= (long)buffer[1] << 8;
@ -978,7 +978,8 @@ r_object(RFILE *p)
case TYPE_FLOAT: case TYPE_FLOAT:
{ {
char buf[256], *ptr; char buf[256];
const char *ptr;
double dx; double dx;
n = r_byte(p); n = r_byte(p);
if (n == EOF) { if (n == EOF) {
@ -1001,9 +1002,9 @@ r_object(RFILE *p)
case TYPE_BINARY_FLOAT: case TYPE_BINARY_FLOAT:
{ {
unsigned char *buf; const unsigned char *buf;
double x; double x;
buf = (unsigned char *) r_string(8, p); buf = (const unsigned char *) r_string(8, p);
if (buf == NULL) if (buf == NULL)
break; break;
x = _PyFloat_Unpack8(buf, 1); x = _PyFloat_Unpack8(buf, 1);
@ -1016,7 +1017,8 @@ r_object(RFILE *p)
case TYPE_COMPLEX: case TYPE_COMPLEX:
{ {
char buf[256], *ptr; char buf[256];
const char *ptr;
Py_complex c; Py_complex c;
n = r_byte(p); n = r_byte(p);
if (n == EOF) { if (n == EOF) {
@ -1053,15 +1055,15 @@ r_object(RFILE *p)
case TYPE_BINARY_COMPLEX: case TYPE_BINARY_COMPLEX:
{ {
unsigned char *buf; const unsigned char *buf;
Py_complex c; Py_complex c;
buf = (unsigned char *) r_string(8, p); buf = (const unsigned char *) r_string(8, p);
if (buf == NULL) if (buf == NULL)
break; break;
c.real = _PyFloat_Unpack8(buf, 1); c.real = _PyFloat_Unpack8(buf, 1);
if (c.real == -1.0 && PyErr_Occurred()) if (c.real == -1.0 && PyErr_Occurred())
break; break;
buf = (unsigned char *) r_string(8, p); buf = (const unsigned char *) r_string(8, p);
if (buf == NULL) if (buf == NULL)
break; break;
c.imag = _PyFloat_Unpack8(buf, 1); c.imag = _PyFloat_Unpack8(buf, 1);
@ -1074,7 +1076,7 @@ r_object(RFILE *p)
case TYPE_STRING: case TYPE_STRING:
{ {
char *ptr; const char *ptr;
n = r_long(p); n = r_long(p);
if (PyErr_Occurred()) if (PyErr_Occurred())
break; break;
@ -1119,7 +1121,7 @@ r_object(RFILE *p)
} }
_read_ascii: _read_ascii:
{ {
char *ptr; const char *ptr;
ptr = r_string(n, p); ptr = r_string(n, p);
if (ptr == NULL) if (ptr == NULL)
break; break;
@ -1137,7 +1139,7 @@ r_object(RFILE *p)
is_interned = 1; is_interned = 1;
case TYPE_UNICODE: case TYPE_UNICODE:
{ {
char *buffer; const char *buffer;
n = r_long(p); n = r_long(p);
if (PyErr_Occurred()) if (PyErr_Occurred())

View File

@ -301,7 +301,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
case 'U': /* XXX deprecated alias */ case 'U': /* XXX deprecated alias */
{ {
PyObject *v; PyObject *v;
char *str = va_arg(*p_va, char *); const char *str = va_arg(*p_va, const char *);
Py_ssize_t n; Py_ssize_t n;
if (**p_format == '#') { if (**p_format == '#') {
++*p_format; ++*p_format;
@ -334,7 +334,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
case 'y': case 'y':
{ {
PyObject *v; PyObject *v;
char *str = va_arg(*p_va, char *); const char *str = va_arg(*p_va, const char *);
Py_ssize_t n; Py_ssize_t n;
if (**p_format == '#') { if (**p_format == '#') {
++*p_format; ++*p_format;

View File

@ -1004,8 +1004,8 @@ is_valid_fd(int fd)
/* returns Py_None if the fd is not valid */ /* returns Py_None if the fd is not valid */
static PyObject* static PyObject*
create_stdio(PyObject* io, create_stdio(PyObject* io,
int fd, int write_mode, char* name, int fd, int write_mode, const char* name,
char* encoding, char* errors) const char* encoding, const char* errors)
{ {
PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res; PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res;
const char* mode; const char* mode;

View File

@ -1138,8 +1138,8 @@ PyParser_ASTFromString(const char *s, const char *filename_str, int start,
mod_ty mod_ty
PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc, PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,
int start, char *ps1, int start, const char *ps1,
char *ps2, PyCompilerFlags *flags, int *errcode, const char *ps2, PyCompilerFlags *flags, int *errcode,
PyArena *arena) PyArena *arena)
{ {
mod_ty mod; mod_ty mod;
@ -1171,8 +1171,8 @@ PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,
mod_ty mod_ty
PyParser_ASTFromFile(FILE *fp, const char *filename_str, const char* enc, PyParser_ASTFromFile(FILE *fp, const char *filename_str, const char* enc,
int start, char *ps1, int start, const char *ps1,
char *ps2, PyCompilerFlags *flags, int *errcode, const char *ps2, PyCompilerFlags *flags, int *errcode,
PyArena *arena) PyArena *arena)
{ {
mod_ty mod; mod_ty mod;

View File

@ -160,7 +160,7 @@ PyTypeObject PySTEntry_Type = {
}; };
static int symtable_analyze(struct symtable *st); static int symtable_analyze(struct symtable *st);
static int symtable_warn(struct symtable *st, char *msg, int lineno); static int symtable_warn(struct symtable *st, const char *msg, int lineno);
static int symtable_enter_block(struct symtable *st, identifier name, static int symtable_enter_block(struct symtable *st, identifier name,
_Py_block_ty block, void *ast, int lineno, _Py_block_ty block, void *ast, int lineno,
int col_offset); int col_offset);
@ -903,7 +903,7 @@ symtable_analyze(struct symtable *st)
static int static int
symtable_warn(struct symtable *st, char *msg, int lineno) symtable_warn(struct symtable *st, const char *msg, int lineno)
{ {
PyObject *message = PyUnicode_FromString(msg); PyObject *message = PyUnicode_FromString(msg);
if (message == NULL) if (message == NULL)