Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/_ctypes/callproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args)
handle = ctypes_dlopen(name_str, mode);
Py_XDECREF(name2);
if (!handle) {
char *errmsg = ctypes_dlerror();
const char *errmsg = ctypes_dlerror();
if (!errmsg)
errmsg = "dlopen() error";
PyErr_SetString(PyExc_OSError,
Expand Down
4 changes: 2 additions & 2 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

/* Release Number */

char *PyCursesVersion = "2.2";
static const char PyCursesVersion[] = "2.2";

/* Includes */

Expand Down Expand Up @@ -2562,7 +2562,7 @@ PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds)
}

if (!initialised_setupterm && setupterm(termstr,fd,&err) == ERR) {
char* s = "setupterm: unknown error";
const char* s = "setupterm: unknown error";

if (err == 0) {
s = "setupterm: could not find terminal";
Expand Down
2 changes: 1 addition & 1 deletion Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ static PyObject *
pysqlite_connection_exit(pysqlite_Connection* self, PyObject* args)
{
PyObject* exc_type, *exc_value, *exc_tb;
char* method_name;
const char* method_name;
PyObject* result;

if (!PyArg_ParseTuple(args, "OOO", &exc_type, &exc_value, &exc_tb)) {
Expand Down
2 changes: 1 addition & 1 deletion Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2413,7 +2413,7 @@ test_with_docstring(PyObject *self)
static PyObject *
test_string_to_double(PyObject *self) {
double result;
char *msg;
const char *msg;

#define CHECK_STRING(STR, expected) \
result = PyOS_string_to_double(STR, NULL, NULL); \
Expand Down
3 changes: 2 additions & 1 deletion Modules/fpectlmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ static void fpe_reset(Sigfunc *handler)
extern long ieee_handler(const char*, const char*, sigfpe_handler_type);
#endif

char *mode="exception", *in="all", *out;
const char *mode="exception", *in="all";
char *out;
(void) nonstandard_arithmetic();
(void) ieee_flags("clearall",mode,in,&out);
(void) ieee_handler("set","common",(sigfpe_handler_type)handler);
Expand Down
2 changes: 1 addition & 1 deletion Modules/gcmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ _PyGC_DumpShutdownStats(void)
{
if (!(_PyRuntime.gc.debug & DEBUG_SAVEALL)
&& _PyRuntime.gc.garbage != NULL && PyList_GET_SIZE(_PyRuntime.gc.garbage) > 0) {
char *message;
const char *message;
if (_PyRuntime.gc.debug & DEBUG_UNCOLLECTABLE)
message = "gc: %zd uncollectable objects at " \
"shutdown";
Expand Down
2 changes: 1 addition & 1 deletion Modules/getaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ getaddrinfo(const char*hostname, const char*servname,
port = htons((u_short)atoi(servname));
} else {
struct servent *sp;
char *proto;
const char *proto;

proto = NULL;
switch (pai->ai_socktype) {
Expand Down
2 changes: 1 addition & 1 deletion Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ static int
run_file(FILE *fp, const wchar_t *filename, PyCompilerFlags *p_cf)
{
PyObject *unicode, *bytes = NULL;
char *filename_str;
const char *filename_str;
int run;

/* call pending calls like signal handlers (SIGINT) */
Expand Down
2 changes: 1 addition & 1 deletion Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
DWORD off_lo; /* lower 32 bits of offset */
DWORD size_hi; /* upper 32 bits of size */
DWORD size_lo; /* lower 32 bits of size */
char *tagname = "";
const char *tagname = "";
DWORD dwErr = 0;
int fileno;
HANDLE fh = 0;
Expand Down
8 changes: 4 additions & 4 deletions Modules/ossaudiodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef unsigned long uint32_t;

typedef struct {
PyObject_HEAD
char *devicename; /* name of the device file */
const char *devicename; /* name of the device file */
int fd; /* file descriptor */
int mode; /* file mode (O_RDONLY, etc.) */
Py_ssize_t icount; /* input count */
Expand Down Expand Up @@ -82,8 +82,8 @@ newossobject(PyObject *arg)
{
oss_audio_t *self;
int fd, afmts, imode;
char *devicename = NULL;
char *mode = NULL;
const char *devicename = NULL;
const char *mode = NULL;

/* Two ways to call open():
open(device, mode) (for consistency with builtin open())
Expand Down Expand Up @@ -167,7 +167,7 @@ oss_dealloc(oss_audio_t *self)
static oss_mixer_t *
newossmixerobject(PyObject *arg)
{
char *devicename = NULL;
const char *devicename = NULL;
int fd;
oss_mixer_t *self;

Expand Down
15 changes: 9 additions & 6 deletions Objects/bytearrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,8 @@ bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes)
/*[clinic end generated code: output=760412661a34ad5a input=ef7bb59b09c21d62]*/
{
Py_ssize_t left, right, mysize, byteslen;
char *myptr, *bytesptr;
char *myptr;
const char *bytesptr;
Py_buffer vbytes;

if (bytes == Py_None) {
Expand All @@ -1816,7 +1817,7 @@ bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes)
else {
if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0)
return NULL;
bytesptr = (char *) vbytes.buf;
bytesptr = (const char *) vbytes.buf;
byteslen = vbytes.len;
}
myptr = PyByteArray_AS_STRING(self);
Expand Down Expand Up @@ -1847,7 +1848,8 @@ bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes)
/*[clinic end generated code: output=d005c9d0ab909e66 input=80843f975dd7c480]*/
{
Py_ssize_t left, right, mysize, byteslen;
char *myptr, *bytesptr;
char *myptr;
const char *bytesptr;
Py_buffer vbytes;

if (bytes == Py_None) {
Expand All @@ -1857,7 +1859,7 @@ bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes)
else {
if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0)
return NULL;
bytesptr = (char *) vbytes.buf;
bytesptr = (const char *) vbytes.buf;
byteslen = vbytes.len;
}
myptr = PyByteArray_AS_STRING(self);
Expand Down Expand Up @@ -1885,7 +1887,8 @@ bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes)
/*[clinic end generated code: output=030e2fbd2f7276bd input=e728b994954cfd91]*/
{
Py_ssize_t right, mysize, byteslen;
char *myptr, *bytesptr;
char *myptr;
const char *bytesptr;
Py_buffer vbytes;

if (bytes == Py_None) {
Expand All @@ -1895,7 +1898,7 @@ bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes)
else {
if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0)
return NULL;
bytesptr = (char *) vbytes.buf;
bytesptr = (const char *) vbytes.buf;
byteslen = vbytes.len;
}
myptr = PyByteArray_AS_STRING(self);
Expand Down
2 changes: 1 addition & 1 deletion Objects/classobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ instancemethod_repr(PyObject *self)
{
PyObject *func = PyInstanceMethod_Function(self);
PyObject *funcname = NULL , *result = NULL;
char *defname = "?";
const char *defname = "?";

if (func == NULL) {
PyErr_BadInternalCall();
Expand Down
6 changes: 3 additions & 3 deletions Objects/complexobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ complex_repr(PyComplexObject *v)
/* These do not need to be freed. re is either an alias
for pre or a pointer to a constant. lead and tail
are pointers to constants. */
char *re = NULL;
char *lead = "";
char *tail = "";
const char *re = NULL;
const char *lead = "";
const char *tail = "";

if (v->cval.real == 0. && copysign(1.0, v->cval.real)==1.0) {
/* Real part is +0: just output the imaginary part and do not
Expand Down
8 changes: 4 additions & 4 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing)
PyObject *result;

if (gen->gi_running) {
char *msg = "generator already executing";
const char *msg = "generator already executing";
if (PyCoro_CheckExact(gen)) {
msg = "coroutine already executing";
}
Expand Down Expand Up @@ -186,8 +186,8 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing)

if (f->f_lasti == -1) {
if (arg && arg != Py_None) {
char *msg = "can't send non-None value to a "
"just-started generator";
const char *msg = "can't send non-None value to a "
"just-started generator";
if (PyCoro_CheckExact(gen)) {
msg = NON_INIT_CORO_MSG;
}
Expand Down Expand Up @@ -410,7 +410,7 @@ gen_close(PyGenObject *gen, PyObject *args)
PyErr_SetNone(PyExc_GeneratorExit);
retval = gen_send_ex(gen, Py_None, 1, 1);
if (retval) {
char *msg = "generator ignored GeneratorExit";
const char *msg = "generator ignored GeneratorExit";
if (PyCoro_CheckExact(gen)) {
msg = "coroutine ignored GeneratorExit";
} else if (PyAsyncGen_CheckExact(gen)) {
Expand Down
4 changes: 2 additions & 2 deletions Objects/obmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ _PyMem_DebugCheckAddress(char api, const void *p)
{
const uint8_t *q = (const uint8_t *)p;
char msgbuf[64];
char *msg;
const char *msg;
size_t nbytes;
const uint8_t *tail;
int i;
Expand All @@ -1661,7 +1661,7 @@ _PyMem_DebugCheckAddress(char api, const void *p)
id = (char)q[-SST];
if (id != api) {
msg = msgbuf;
snprintf(msg, sizeof(msgbuf), "bad ID: Allocated using API '%c', verified using API '%c'", id, api);
snprintf(msgbuf, sizeof(msgbuf), "bad ID: Allocated using API '%c', verified using API '%c'", id, api);
msgbuf[sizeof(msgbuf)-1] = 0;
goto error;
}
Expand Down
4 changes: 2 additions & 2 deletions Objects/odictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ odict_init(PyObject *self, PyObject *args, PyObject *kwds)
if (len == -1)
return -1;
if (len > 1) {
char *msg = "expected at most 1 arguments, got %d";
const char *msg = "expected at most 1 arguments, got %d";
PyErr_Format(PyExc_TypeError, msg, len);
return -1;
}
Expand Down Expand Up @@ -2337,7 +2337,7 @@ mutablemapping_update(PyObject *self, PyObject *args, PyObject *kwargs)
assert(args == NULL || PyTuple_Check(args));
len = (args != NULL) ? PyTuple_GET_SIZE(args) : 0;
if (len > 1) {
char *msg = "update() takes at most 1 positional argument (%d given)";
const char *msg = "update() takes at most 1 positional argument (%d given)";
PyErr_Format(PyExc_TypeError, msg, len);
return NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -8396,8 +8396,8 @@ charmap_encoding_error(
Py_ssize_t collstartpos = *inpos;
Py_ssize_t collendpos = *inpos+1;
Py_ssize_t collpos;
char *encoding = "charmap";
char *reason = "character maps to <undefined>";
const char *encoding = "charmap";
const char *reason = "character maps to <undefined>";
charmapencode_result x;
Py_UCS4 ch;
int val;
Expand Down Expand Up @@ -8928,7 +8928,7 @@ _PyUnicode_TranslateCharmap(PyObject *input,
/* output buffer */
_PyUnicodeWriter writer;
/* error handler */
char *reason = "character maps to <undefined>";
const char *reason = "character maps to <undefined>";
PyObject *errorHandler = NULL;
PyObject *exc = NULL;
int ignore;
Expand Down
2 changes: 1 addition & 1 deletion PC/bdist_wininst/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,7 @@ SelectPythonDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

if (count == 0) {
char Buffer[4096];
char *msg;
const char *msg;
if (target_version && target_version[0]) {
wsprintf(Buffer,
"Python version %s required, which was not found"
Expand Down
2 changes: 1 addition & 1 deletion Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
/* If we're interactive, use (GNU) readline */
if (tty) {
PyObject *po = NULL;
char *promptstr;
const char *promptstr;
char *s = NULL;
PyObject *stdin_encoding = NULL, *stdin_errors = NULL;
PyObject *stdout_encoding = NULL, *stdout_errors = NULL;
Expand Down
2 changes: 1 addition & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -4846,7 +4846,7 @@ compiler_visit_nested_slice(struct compiler *c, slice_ty s,
static int
compiler_visit_slice(struct compiler *c, slice_ty s, expr_context_ty ctx)
{
char * kindname = NULL;
const char * kindname = NULL;
switch (s->kind) {
case Index_kind:
kindname = "index";
Expand Down
2 changes: 1 addition & 1 deletion Python/pyhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ _PyHash_Fini(void)
#ifdef Py_HASH_STATS
int i;
Py_ssize_t total = 0;
char *fmt = "%2i %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n";
const char *fmt = "%2i %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n";

fprintf(stderr, "len calls total\n");
for (i = 1; i <= Py_HASH_STATS_MAX; i++) {
Expand Down
3 changes: 2 additions & 1 deletion Python/pystrtod.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ Py_LOCAL_INLINE(char *)
ensure_decimal_point(char* buffer, size_t buf_size, int precision)
{
int digit_count, insert_count = 0, convert_to_exp = 0;
char *chars_to_insert, *digits_start;
const char *chars_to_insert;
char *digits_start;

/* search for the first non-digit character */
char *p = buffer;
Expand Down
2 changes: 1 addition & 1 deletion Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ err_input(perrdetail *err)
{
PyObject *v, *w, *errtype, *errtext;
PyObject *msg_obj = NULL;
char *msg = NULL;
const char *msg = NULL;
int offset = err->offset;

errtype = PyExc_SyntaxError;
Expand Down