diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2005-12-10 18:50:16 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2005-12-10 18:50:16 (GMT) |
commit | af68c874a6803b4e90b616077a602c0593719a1d (patch) | |
tree | c7361b29cf629171b4da8e51cfd1074f67d814a7 /Modules | |
parent | aaa2f1dea706daf2a5f431d97a3e3120dba652d2 (diff) | |
download | cpython-af68c874a6803b4e90b616077a602c0593719a1d.zip cpython-af68c874a6803b4e90b616077a602c0593719a1d.tar.gz cpython-af68c874a6803b4e90b616077a602c0593719a1d.tar.bz2 |
Add const to several API functions that take char *.
In C++, it's an error to pass a string literal to a char* function
without a const_cast(). Rather than require every C++ extension
module to put a cast around string literals, fix the API to state the
const-ness.
I focused on parts of the API where people usually pass literals:
PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type
slots, etc. Predictably, there were a large set of functions that
needed to be fixed as a result of these changes. The most pervasive
change was to make the keyword args list passed to
PyArg_ParseTupleAndKewords() to be a const char *kwlist[].
One cast was required as a result of the changes: A type object
mallocs the memory for its tp_doc slot and later frees it.
PyTypeObject says that tp_doc is const char *; but if the type was
created by type_new(), we know it is safe to cast to char *.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_bisectmodule.c | 9 | ||||
-rw-r--r-- | Modules/_bsddb.c | 78 | ||||
-rw-r--r-- | Modules/_csv.c | 2 | ||||
-rw-r--r-- | Modules/_cursesmodule.c | 4 | ||||
-rw-r--r-- | Modules/_hashopenssl.c | 4 | ||||
-rw-r--r-- | Modules/_sre.c | 16 | ||||
-rw-r--r-- | Modules/_tkinter.c | 4 | ||||
-rw-r--r-- | Modules/binascii.c | 5 | ||||
-rw-r--r-- | Modules/bz2module.c | 8 | ||||
-rw-r--r-- | Modules/cPickle.c | 20 | ||||
-rw-r--r-- | Modules/cStringIO.c | 2 | ||||
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 4 | ||||
-rw-r--r-- | Modules/datetimemodule.c | 32 | ||||
-rw-r--r-- | Modules/itertoolsmodule.c | 2 | ||||
-rw-r--r-- | Modules/mmapmodule.c | 15 | ||||
-rw-r--r-- | Modules/parsermodule.c | 18 | ||||
-rw-r--r-- | Modules/pyexpat.c | 4 | ||||
-rw-r--r-- | Modules/sha256module.c | 4 | ||||
-rw-r--r-- | Modules/sha512module.c | 4 | ||||
-rw-r--r-- | Modules/socketmodule.c | 2 |
20 files changed, 124 insertions, 113 deletions
diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c index 0d29462..e40297d 100644 --- a/Modules/_bisectmodule.c +++ b/Modules/_bisectmodule.c @@ -40,7 +40,7 @@ bisect_right(PyObject *self, PyObject *args, PyObject *kw) int lo = 0; int hi = -1; int index; - static char *keywords[] = {"a", "x", "lo", "hi", NULL}; + static const char *keywords[] = {"a", "x", "lo", "hi", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|ii:bisect_right", keywords, &list, &item, &lo, &hi)) @@ -70,7 +70,7 @@ insort_right(PyObject *self, PyObject *args, PyObject *kw) int lo = 0; int hi = -1; int index; - static char *keywords[] = {"a", "x", "lo", "hi", NULL}; + static const char *keywords[] = {"a", "x", "lo", "hi", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|ii:insort_right", keywords, &list, &item, &lo, &hi)) @@ -137,7 +137,7 @@ bisect_left(PyObject *self, PyObject *args, PyObject *kw) int lo = 0; int hi = -1; int index; - static char *keywords[] = {"a", "x", "lo", "hi", NULL}; + static const char *keywords[] = {"a", "x", "lo", "hi", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|ii:bisect_left", keywords, &list, &item, &lo, &hi)) @@ -167,7 +167,7 @@ insort_left(PyObject *self, PyObject *args, PyObject *kw) int lo = 0; int hi = -1; int index; - static char *keywords[] = {"a", "x", "lo", "hi", NULL}; + static const char *keywords[] = {"a", "x", "lo", "hi", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|ii:insort_left", keywords, &list, &item, &lo, &hi)) @@ -233,4 +233,3 @@ init_bisect(void) m = Py_InitModule3("_bisect", bisect_methods, module_doc); } - diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index f493ecb..59931c3 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -650,7 +650,7 @@ static PyObject* _DBCursor_get(DBCursorObject* self, int extra_flags, int dlen = -1; int doff = -1; int flags = 0; - char* kwnames[] = { "flags", "dlen", "doff", NULL }; + static const char* kwnames[] = { "flags", "dlen", "doff", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, format, kwnames, &flags, &dlen, &doff)) @@ -1147,9 +1147,10 @@ DB_associate(DBObject* self, PyObject* args, PyObject* kwargs) #if (DBVER >= 41) PyObject *txnobj = NULL; DB_TXN *txn = NULL; - char* kwnames[] = {"secondaryDB", "callback", "flags", "txn", NULL}; + static const char* kwnames[] = {"secondaryDB", "callback", "flags", "txn", + NULL}; #else - char* kwnames[] = {"secondaryDB", "callback", "flags", NULL}; + static const char* kwnames[] = {"secondaryDB", "callback", "flags", NULL}; #endif #if (DBVER >= 41) @@ -1255,7 +1256,7 @@ _DB_consume(DBObject* self, PyObject* args, PyObject* kwargs, int consume_flag) PyObject* retval = NULL; DBT key, data; DB_TXN *txn = NULL; - char* kwnames[] = { "txn", "flags", NULL }; + static const char* kwnames[] = { "txn", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:consume", kwnames, &txnobj, &flags)) @@ -1325,7 +1326,7 @@ DB_cursor(DBObject* self, PyObject* args, PyObject* kwargs) DBC* dbc; PyObject* txnobj = NULL; DB_TXN *txn = NULL; - char* kwnames[] = { "txn", "flags", NULL }; + static const char* kwnames[] = { "txn", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:cursor", kwnames, &txnobj, &flags)) @@ -1350,7 +1351,7 @@ DB_delete(DBObject* self, PyObject* args, PyObject* kwargs) PyObject* keyobj; DBT key; DB_TXN *txn = NULL; - char* kwnames[] = { "key", "txn", "flags", NULL }; + static const char* kwnames[] = { "key", "txn", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi:delete", kwnames, &keyobj, &txnobj, &flags)) @@ -1402,7 +1403,8 @@ DB_get(DBObject* self, PyObject* args, PyObject* kwargs) int doff = -1; DBT key, data; DB_TXN *txn = NULL; - char* kwnames[] = {"key", "default", "txn", "flags", "dlen", "doff", NULL}; + static const char* kwnames[] = {"key", "default", "txn", "flags", "dlen", + "doff", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOiii:get", kwnames, &keyobj, &dfltobj, &txnobj, &flags, &dlen, @@ -1469,7 +1471,8 @@ DB_pget(DBObject* self, PyObject* args, PyObject* kwargs) int doff = -1; DBT key, pkey, data; DB_TXN *txn = NULL; - char* kwnames[] = {"key", "default", "txn", "flags", "dlen", "doff", NULL}; + static const char* kwnames[] = {"key", "default", "txn", "flags", "dlen", + "doff", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOiii:pget", kwnames, &keyobj, &dfltobj, &txnobj, &flags, &dlen, @@ -1558,7 +1561,7 @@ DB_get_size(DBObject* self, PyObject* args, PyObject* kwargs) PyObject* retval = NULL; DBT key, data; DB_TXN *txn = NULL; - char* kwnames[] = { "key", "txn", NULL }; + static const char* kwnames[] = { "key", "txn", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:get_size", kwnames, &keyobj, &txnobj)) @@ -1601,7 +1604,7 @@ DB_get_both(DBObject* self, PyObject* args, PyObject* kwargs) PyObject* retval = NULL; DBT key, data; DB_TXN *txn = NULL; - char* kwnames[] = { "key", "data", "txn", "flags", NULL }; + static const char* kwnames[] = { "key", "data", "txn", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|Oi:get_both", kwnames, @@ -1752,7 +1755,7 @@ DB_key_range(DBObject* self, PyObject* args, PyObject* kwargs) DBT key; DB_TXN *txn = NULL; DB_KEY_RANGE range; - char* kwnames[] = { "key", "txn", "flags", NULL }; + static const char* kwnames[] = { "key", "txn", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi:key_range", kwnames, &keyobj, &txnobj, &flags)) @@ -1783,17 +1786,17 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs) PyObject *txnobj = NULL; DB_TXN *txn = NULL; /* with dbname */ - char* kwnames[] = { + static const char* kwnames[] = { "filename", "dbname", "dbtype", "flags", "mode", "txn", NULL}; /* without dbname */ - char* kwnames_basic[] = { + static const char* kwnames_basic[] = { "filename", "dbtype", "flags", "mode", "txn", NULL}; #else /* with dbname */ - char* kwnames[] = { + static const char* kwnames[] = { "filename", "dbname", "dbtype", "flags", "mode", NULL}; /* without dbname */ - char* kwnames_basic[] = { + static const char* kwnames_basic[] = { "filename", "dbtype", "flags", "mode", NULL}; #endif @@ -1877,7 +1880,8 @@ DB_put(DBObject* self, PyObject* args, PyObject* kwargs) PyObject* keyobj, *dataobj, *retval; DBT key, data; DB_TXN *txn = NULL; - char* kwnames[] = { "key", "data", "txn", "flags", "dlen", "doff", NULL }; + static const char* kwnames[] = { "key", "data", "txn", "flags", "dlen", + "doff", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|Oiii:put", kwnames, &keyobj, &dataobj, &txnobj, &flags, &dlen, &doff)) @@ -1917,7 +1921,7 @@ DB_remove(DBObject* self, PyObject* args, PyObject* kwargs) char* filename; char* database = NULL; int err, flags=0; - char* kwnames[] = { "filename", "dbname", "flags", NULL}; + static const char* kwnames[] = { "filename", "dbname", "flags", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zi:remove", kwnames, &filename, &database, &flags)) @@ -2335,9 +2339,9 @@ DB_stat(DBObject* self, PyObject* args, PyObject* kwargs) #if (DBVER >= 43) PyObject* txnobj = NULL; DB_TXN *txn = NULL; - char* kwnames[] = { "txn", "flags", NULL }; + static const char* kwnames[] = { "txn", "flags", NULL }; #else - char* kwnames[] = { "flags", NULL }; + static const char* kwnames[] = { "flags", NULL }; #endif #if (DBVER >= 43) @@ -2477,7 +2481,7 @@ DB_truncate(DBObject* self, PyObject* args, PyObject* kwargs) u_int32_t count=0; PyObject* txnobj = NULL; DB_TXN *txn = NULL; - char* kwnames[] = { "txn", "flags", NULL }; + static const char* kwnames[] = { "txn", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:cursor", kwnames, &txnobj, &flags)) @@ -2521,7 +2525,8 @@ DB_verify(DBObject* self, PyObject* args, PyObject* kwargs) char* dbName=NULL; char* outFileName=NULL; FILE* outFile=NULL; - char* kwnames[] = { "filename", "dbname", "outfile", "flags", NULL }; + static const char* kwnames[] = { "filename", "dbname", "outfile", "flags", + NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zzi:verify", kwnames, &fileName, &dbName, &outFileName, &flags)) @@ -2578,7 +2583,7 @@ DB_set_encrypt(DBObject* self, PyObject* args, PyObject* kwargs) int err; u_int32_t flags=0; char *passwd = NULL; - char* kwnames[] = { "passwd", "flags", NULL }; + static const char* kwnames[] = { "passwd", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i:set_encrypt", kwnames, &passwd, &flags)) { @@ -3018,7 +3023,8 @@ DBC_get(DBCursorObject* self, PyObject* args, PyObject *kwargs) int dlen = -1; int doff = -1; DBT key, data; - char* kwnames[] = { "key","data", "flags", "dlen", "doff", NULL }; + static const char* kwnames[] = { "key","data", "flags", "dlen", "doff", + NULL }; CLEAR_DBT(key); CLEAR_DBT(data); @@ -3104,7 +3110,8 @@ DBC_pget(DBCursorObject* self, PyObject* args, PyObject *kwargs) int dlen = -1; int doff = -1; DBT key, pkey, data; - char* kwnames[] = { "key","data", "flags", "dlen", "doff", NULL }; + static const char* kwnames[] = { "key","data", "flags", "dlen", "doff", + NULL }; CLEAR_DBT(key); CLEAR_DBT(data); @@ -3257,7 +3264,8 @@ DBC_put(DBCursorObject* self, PyObject* args, PyObject* kwargs) int err, flags = 0; PyObject* keyobj, *dataobj; DBT key, data; - char* kwnames[] = { "key", "data", "flags", "dlen", "doff", NULL }; + static const char* kwnames[] = { "key", "data", "flags", "dlen", "doff", + NULL }; int dlen = -1; int doff = -1; @@ -3292,7 +3300,7 @@ DBC_set(DBCursorObject* self, PyObject* args, PyObject *kwargs) int err, flags = 0; DBT key, data; PyObject* retval, *keyobj; - char* kwnames[] = { "key", "flags", "dlen", "doff", NULL }; + static const char* kwnames[] = { "key", "flags", "dlen", "doff", NULL }; int dlen = -1; int doff = -1; @@ -3362,7 +3370,7 @@ DBC_set_range(DBCursorObject* self, PyObject* args, PyObject* kwargs) int err, flags = 0; DBT key, data; PyObject* retval, *keyobj; - char* kwnames[] = { "key", "flags", "dlen", "doff", NULL }; + static const char* kwnames[] = { "key", "flags", "dlen", "doff", NULL }; int dlen = -1; int doff = -1; @@ -3552,7 +3560,7 @@ DBC_set_recno(DBCursorObject* self, PyObject* args, PyObject *kwargs) PyObject* retval; int dlen = -1; int doff = -1; - char* kwnames[] = { "recno","flags", "dlen", "doff", NULL }; + static const char* kwnames[] = { "recno","flags", "dlen", "doff", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|iii:set_recno", kwnames, &irecno, &flags, &dlen, &doff)) @@ -3746,7 +3754,8 @@ DBEnv_dbremove(DBEnvObject* self, PyObject* args, PyObject* kwargs) char *database = NULL; PyObject *txnobj = NULL; DB_TXN *txn = NULL; - char* kwnames[] = { "file", "database", "txn", "flags", NULL }; + static const char* kwnames[] = { "file", "database", "txn", "flags", + NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss|Oi:dbremove", kwnames, &file, &database, &txnobj, &flags)) { @@ -3773,7 +3782,8 @@ DBEnv_dbrename(DBEnvObject* self, PyObject* args, PyObject* kwargs) char *newname = NULL; PyObject *txnobj = NULL; DB_TXN *txn = NULL; - char* kwnames[] = { "file", "database", "newname", "txn", "flags", NULL }; + static const char* kwnames[] = { "file", "database", "newname", "txn", + "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss|Oi:dbrename", kwnames, &file, &database, &newname, &txnobj, &flags)) { @@ -3797,7 +3807,7 @@ DBEnv_set_encrypt(DBEnvObject* self, PyObject* args, PyObject* kwargs) int err; u_int32_t flags=0; char *passwd = NULL; - char* kwnames[] = { "passwd", "flags", NULL }; + static const char* kwnames[] = { "passwd", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i:set_encrypt", kwnames, &passwd, &flags)) { @@ -3820,7 +3830,7 @@ DBEnv_set_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs) int err; u_int32_t flags=0; u_int32_t timeout = 0; - char* kwnames[] = { "timeout", "flags", NULL }; + static const char* kwnames[] = { "timeout", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_timeout", kwnames, &timeout, &flags)) { @@ -4107,7 +4117,7 @@ DBEnv_txn_begin(DBEnvObject* self, PyObject* args, PyObject* kwargs) int flags = 0; PyObject* txnobj = NULL; DB_TXN *txn = NULL; - char* kwnames[] = { "parent", "flags", NULL }; + static const char* kwnames[] = { "parent", "flags", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:txn_begin", kwnames, &txnobj, &flags)) @@ -4937,7 +4947,7 @@ DB_construct(PyObject* self, PyObject* args, PyObject* kwargs) { PyObject* dbenvobj = NULL; int flags = 0; - char* kwnames[] = { "dbEnv", "flags", NULL}; + static const char* kwnames[] = { "dbEnv", "flags", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:DB", kwnames, &dbenvobj, &flags)) diff --git a/Modules/_csv.c b/Modules/_csv.c index da5ae0d..51dc89d 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -291,7 +291,7 @@ Dialect_dealloc(DialectObj *self) self->ob_type->tp_free((PyObject *)self); } -static char *dialect_kws[] = { +static const char *dialect_kws[] = { "dialect", "delimiter", "doublequote", diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index acff973..2d7f6e0 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1886,10 +1886,10 @@ PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds) int err; char* termstr = NULL; - static char *kwlist[] = {"term", "fd", NULL}; + static const char *kwlist[] = {"term", "fd", NULL}; if (!PyArg_ParseTupleAndKeywords( - args,keywds,"|zi:setupterm",kwlist,&termstr,&fd)) { + args, keywds, "|zi:setupterm", kwlist, &termstr, &fd)) { return NULL; } diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index bfa180c..c0df605 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -230,7 +230,7 @@ EVP_repr(PyObject *self) static int EVP_tp_init(EVPobject *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = {"name", "string", NULL}; + static const char *kwlist[] = {"name", "string", NULL}; PyObject *name_obj = NULL; char *nameStr; unsigned char *cp = NULL; @@ -366,7 +366,7 @@ The MD5 and SHA1 algorithms are always supported.\n"); static PyObject * EVP_new(PyObject *self, PyObject *args, PyObject *kwdict) { - static char *kwlist[] = {"name", "string", NULL}; + static const char *kwlist[] = {"name", "string", NULL}; PyObject *name_obj = NULL; char *name; const EVP_MD *digest; diff --git a/Modules/_sre.c b/Modules/_sre.c index f97cb62..1f0a8bc 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2007,7 +2007,7 @@ pattern_match(PatternObject* self, PyObject* args, PyObject* kw) PyObject* string; int start = 0; int end = INT_MAX; - static char* kwlist[] = { "pattern", "pos", "endpos", NULL }; + static const char* kwlist[] = { "pattern", "pos", "endpos", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kw, "O|ii:match", kwlist, &string, &start, &end)) return NULL; @@ -2044,7 +2044,7 @@ pattern_search(PatternObject* self, PyObject* args, PyObject* kw) PyObject* string; int start = 0; int end = INT_MAX; - static char* kwlist[] = { "pattern", "pos", "endpos", NULL }; + static const char* kwlist[] = { "pattern", "pos", "endpos", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kw, "O|ii:search", kwlist, &string, &start, &end)) return NULL; @@ -2185,7 +2185,7 @@ pattern_findall(PatternObject* self, PyObject* args, PyObject* kw) PyObject* string; int start = 0; int end = INT_MAX; - static char* kwlist[] = { "source", "pos", "endpos", NULL }; + static const char* kwlist[] = { "source", "pos", "endpos", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kw, "O|ii:findall", kwlist, &string, &start, &end)) return NULL; @@ -2311,7 +2311,7 @@ pattern_split(PatternObject* self, PyObject* args, PyObject* kw) PyObject* string; int maxsplit = 0; - static char* kwlist[] = { "source", "maxsplit", NULL }; + static const char* kwlist[] = { "source", "maxsplit", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kw, "O|i:split", kwlist, &string, &maxsplit)) return NULL; @@ -2595,7 +2595,7 @@ pattern_sub(PatternObject* self, PyObject* args, PyObject* kw) PyObject* template; PyObject* string; int count = 0; - static char* kwlist[] = { "repl", "string", "count", NULL }; + static const char* kwlist[] = { "repl", "string", "count", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|i:sub", kwlist, &template, &string, &count)) return NULL; @@ -2609,7 +2609,7 @@ pattern_subn(PatternObject* self, PyObject* args, PyObject* kw) PyObject* template; PyObject* string; int count = 0; - static char* kwlist[] = { "repl", "string", "count", NULL }; + static const char* kwlist[] = { "repl", "string", "count", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kw, "OO|i:subn", kwlist, &template, &string, &count)) return NULL; @@ -2916,7 +2916,7 @@ match_groups(MatchObject* self, PyObject* args, PyObject* kw) int index; PyObject* def = Py_None; - static char* kwlist[] = { "default", NULL }; + static const char* kwlist[] = { "default", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:groups", kwlist, &def)) return NULL; @@ -2945,7 +2945,7 @@ match_groupdict(MatchObject* self, PyObject* args, PyObject* kw) int index; PyObject* def = Py_None; - static char* kwlist[] = { "default", NULL }; + static const char* kwlist[] = { "default", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kw, "|O:groupdict", kwlist, &def)) return NULL; diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 632f3d6..dd1620a 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -2393,7 +2393,7 @@ Tktt_Repr(PyObject *self) } static PyObject * -Tktt_GetAttr(PyObject *self, char *name) +Tktt_GetAttr(PyObject *self, const char *name) { return Py_FindMethod(Tktt_methods, self, name); } @@ -2723,7 +2723,7 @@ Tkapp_Dealloc(PyObject *self) } static PyObject * -Tkapp_GetAttr(PyObject *self, char *name) +Tkapp_GetAttr(PyObject *self, const char *name) { return Py_FindMethod(Tkapp_methods, self, name); } diff --git a/Modules/binascii.c b/Modules/binascii.c index bfb393f..eab90b3 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -1032,7 +1032,7 @@ binascii_a2b_qp(PyObject *self, PyObject *args, PyObject *kwargs) unsigned char *data, *odata; unsigned int datalen = 0; PyObject *rv; - static char *kwlist[] = {"data", "header", NULL}; + static const char *kwlist[] = {"data", "header", NULL}; int header = 0; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|i", kwlist, &data, @@ -1133,7 +1133,8 @@ binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs) unsigned int datalen = 0, odatalen = 0; PyObject *rv; unsigned int linelen = 0; - static char *kwlist[] = {"data", "quotetabs", "istext", "header", NULL}; + static const char *kwlist[] = {"data", "quotetabs", "istext", + "header", NULL}; int istext = 1; int quotetabs = 0; int header = 0; diff --git a/Modules/bz2module.c b/Modules/bz2module.c index af67ff1..db93675 100644 --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -1285,8 +1285,8 @@ static PyMemberDef BZ2File_members[] = { static int BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = {"filename", "mode", "buffering", - "compresslevel", 0}; + static const char *kwlist[] = {"filename", "mode", "buffering", + "compresslevel", 0}; PyObject *name; char *mode = "r"; int buffering = -1; @@ -1674,7 +1674,7 @@ BZ2Comp_init(BZ2CompObject *self, PyObject *args, PyObject *kwargs) { int compresslevel = 9; int bzerror; - static char *kwlist[] = {"compresslevel", 0}; + static const char *kwlist[] = {"compresslevel", 0}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:BZ2Compressor", kwlist, &compresslevel)) @@ -2019,7 +2019,7 @@ bz2_compress(PyObject *self, PyObject *args, PyObject *kwargs) bz_stream _bzs; bz_stream *bzs = &_bzs; int bzerror; - static char *kwlist[] = {"data", "compresslevel", 0}; + static const char *kwlist[] = {"data", "compresslevel", 0}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|i", kwlist, &data, &datasize, diff --git a/Modules/cPickle.c b/Modules/cPickle.c index 6af99ba..865541f 100644 --- a/Modules/cPickle.c +++ b/Modules/cPickle.c @@ -339,7 +339,7 @@ typedef struct Picklerobject { int fast; /* Fast mode doesn't save in memo, don't use if circ ref */ int nesting; - int (*write_func)(struct Picklerobject *, char *, int); + int (*write_func)(struct Picklerobject *, const char *, int); char *write_buf; int buf_size; PyObject *dispatch_table; @@ -417,7 +417,7 @@ cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...) } static int -write_file(Picklerobject *self, char *s, int n) +write_file(Picklerobject *self, const char *s, int n) { size_t nbyteswritten; @@ -437,7 +437,7 @@ write_file(Picklerobject *self, char *s, int n) } static int -write_cStringIO(Picklerobject *self, char *s, int n) +write_cStringIO(Picklerobject *self, const char *s, int n) { if (s == NULL) { return 0; @@ -451,14 +451,14 @@ write_cStringIO(Picklerobject *self, char *s, int n) } static int -write_none(Picklerobject *self, char *s, int n) +write_none(Picklerobject *self, const char *s, int n) { if (s == NULL) return 0; return n; } static int -write_other(Picklerobject *self, char *s, int n) +write_other(Picklerobject *self, const char *s, int n) { PyObject *py_str = 0, *junk = 0; @@ -669,7 +669,7 @@ readline_other(Unpicklerobject *self, char **s) * The caller is responsible for free()'ing the return value. */ static char * -pystrndup(char *s, int n) +pystrndup(const char *s, int n) { char *r = (char *)malloc(n+1); if (r == NULL) @@ -945,7 +945,7 @@ save_none(Picklerobject *self, PyObject *args) static int save_bool(Picklerobject *self, PyObject *args) { - static char *buf[2] = {FALSE, TRUE}; + static const char *buf[2] = {FALSE, TRUE}; static char len[2] = {sizeof(FALSE)-1, sizeof(TRUE)-1}; long l = PyInt_AS_LONG((PyIntObject *)args); @@ -2858,7 +2858,7 @@ newPicklerobject(PyObject *file, int proto) static PyObject * get_Pickler(PyObject *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = {"file", "protocol", NULL}; + static const char *kwlist[] = {"file", "protocol", NULL}; PyObject *file = NULL; int proto = 0; @@ -5378,7 +5378,7 @@ Unpickler_setattr(Unpicklerobject *self, char *name, PyObject *value) static PyObject * cpm_dump(PyObject *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = {"obj", "file", "protocol", NULL}; + static const char *kwlist[] = {"obj", "file", "protocol", NULL}; PyObject *ob, *file, *res = NULL; Picklerobject *pickler = 0; int proto = 0; @@ -5407,7 +5407,7 @@ cpm_dump(PyObject *self, PyObject *args, PyObject *kwds) static PyObject * cpm_dumps(PyObject *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = {"obj", "protocol", NULL}; + static const char *kwlist[] = {"obj", "protocol", NULL}; PyObject *ob, *file = 0, *res = NULL; Picklerobject *pickler = 0; int proto = 0; diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c index 9ed77d8..0d50459 100644 --- a/Modules/cStringIO.c +++ b/Modules/cStringIO.c @@ -362,7 +362,7 @@ PyDoc_STRVAR(O_write__doc__, static int -O_cwrite(PyObject *self, char *c, int l) { +O_cwrite(PyObject *self, const char *c, int l) { int newl; Oobject *oself; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 7d2d15e..b0dae0c 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -45,8 +45,8 @@ PyDoc_STRVAR(MultibyteCodec_StreamReader__doc__, PyDoc_STRVAR(MultibyteCodec_StreamWriter__doc__, "I.StreamWriter(stream[, errors]) -> StreamWriter instance"); -static char *codeckwarglist[] = {"input", "errors", NULL}; -static char *streamkwarglist[] = {"stream", "errors", NULL}; +static const char *codeckwarglist[] = {"input", "errors", NULL}; +static const char *streamkwarglist[] = {"stream", "errors", NULL}; static PyObject *multibytecodec_encode(MultibyteCodec *, MultibyteCodec_State *, const Py_UNICODE **, size_t, diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index 6b44fe5..8a6fae2 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -1073,10 +1073,10 @@ append_keyword_tzinfo(PyObject *repr, PyObject *tzinfo) static PyObject * format_ctime(PyDateTime_Date *date, int hours, int minutes, int seconds) { - static char *DayNames[] = { + static const char *DayNames[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; - static char *MonthNames[] = { + static const char *MonthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; @@ -1891,7 +1891,7 @@ delta_new(PyTypeObject *type, PyObject *args, PyObject *kw) PyObject *y = NULL; /* temp sum of microseconds */ double leftover_us = 0.0; - static char *keywords[] = { + static const char *keywords[] = { "days", "seconds", "microseconds", "milliseconds", "minutes", "hours", "weeks", NULL }; @@ -2194,7 +2194,7 @@ static PyGetSetDef date_getset[] = { /* Constructors. */ -static char *date_kws[] = {"year", "month", "day", NULL}; +static const char *date_kws[] = {"year", "month", "day", NULL}; static PyObject * date_new(PyTypeObject *type, PyObject *args, PyObject *kw) @@ -2406,7 +2406,7 @@ static PyObject * date_repr(PyDateTime_Date *self) { char buffer[1028]; - char *typename; + const char *typename; typename = self->ob_type->tp_name; PyOS_snprintf(buffer, sizeof(buffer), "%s(%d, %d, %d)", @@ -2448,7 +2448,7 @@ date_strftime(PyDateTime_Date *self, PyObject *args, PyObject *kw) PyObject *result; PyObject *format; PyObject *tuple; - static char *keywords[] = {"format", NULL}; + static const char *keywords[] = {"format", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:strftime", keywords, &PyString_Type, &format)) @@ -3028,7 +3028,7 @@ static PyGetSetDef time_getset[] = { * Constructors. */ -static char *time_kws[] = {"hour", "minute", "second", "microsecond", +static const char *time_kws[] = {"hour", "minute", "second", "microsecond", "tzinfo", NULL}; static PyObject * @@ -3133,7 +3133,7 @@ static PyObject * time_repr(PyDateTime_Time *self) { char buffer[100]; - char *typename = self->ob_type->tp_name; + const char *typename = self->ob_type->tp_name; int h = TIME_GET_HOUR(self); int m = TIME_GET_MINUTE(self); int s = TIME_GET_SECOND(self); @@ -3196,7 +3196,7 @@ time_strftime(PyDateTime_Time *self, PyObject *args, PyObject *kw) PyObject *result; PyObject *format; PyObject *tuple; - static char *keywords[] = {"format", NULL}; + static const char *keywords[] = {"format", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:strftime", keywords, &PyString_Type, &format)) @@ -3548,7 +3548,7 @@ static PyGetSetDef datetime_getset[] = { * Constructors. */ -static char *datetime_kws[] = { +static const char *datetime_kws[] = { "year", "month", "day", "hour", "minute", "second", "microsecond", "tzinfo", NULL }; @@ -3729,7 +3729,7 @@ datetime_now(PyObject *cls, PyObject *args, PyObject *kw) { PyObject *self; PyObject *tzinfo = Py_None; - static char *keywords[] = {"tz", NULL}; + static const char *keywords[] = {"tz", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kw, "|O:now", keywords, &tzinfo)) @@ -3765,7 +3765,7 @@ datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw) PyObject *self; double timestamp; PyObject *tzinfo = Py_None; - static char *keywords[] = {"timestamp", "tz", NULL}; + static const char *keywords[] = {"timestamp", "tz", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kw, "d|O:fromtimestamp", keywords, ×tamp, &tzinfo)) @@ -3843,7 +3843,7 @@ datetime_strptime(PyObject *cls, PyObject *args) static PyObject * datetime_combine(PyObject *cls, PyObject *args, PyObject *kw) { - static char *keywords[] = {"date", "time", NULL}; + static const char *keywords[] = {"date", "time", NULL}; PyObject *date; PyObject *time; PyObject *result = NULL; @@ -4027,7 +4027,7 @@ static PyObject * datetime_repr(PyDateTime_DateTime *self) { char buffer[1000]; - char *typename = self->ob_type->tp_name; + const char *typename = self->ob_type->tp_name; PyObject *baserepr; if (DATE_GET_MICROSECOND(self)) { @@ -4070,7 +4070,7 @@ static PyObject * datetime_isoformat(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) { char sep = 'T'; - static char *keywords[] = {"sep", NULL}; + static const char *keywords[] = {"sep", NULL}; char buffer[100]; char *cp; PyObject *result; @@ -4261,7 +4261,7 @@ datetime_astimezone(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) int offset, none; PyObject *tzinfo; - static char *keywords[] = {"tz", NULL}; + static const char *keywords[] = {"tz", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:astimezone", keywords, &PyDateTime_TZInfoType, &tzinfo)) diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 5ec5b8d..c675bf4 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -26,7 +26,7 @@ static PyObject *_grouper_create(groupbyobject *, PyObject *); static PyObject * groupby_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - static char *kwargs[] = {"iterable", "key", NULL}; + static const char *kwargs[] = {"iterable", "key", NULL}; groupbyobject *gbo; PyObject *it, *keyfunc = Py_None; diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 51487a7..7796ced 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -864,12 +864,13 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) int map_size; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; access_mode access = ACCESS_DEFAULT; - char *keywords[] = {"fileno", "length", - "flags", "prot", - "access", NULL}; + static const char *keywords[] = {"fileno", "length", + "flags", "prot", + "access", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iii", keywords, - &fd, &map_size_obj, &flags, &prot, &access)) + &fd, &map_size_obj, &flags, &prot, + &access)) return NULL; map_size = _GetMapSize(map_size_obj); if (map_size < 0) @@ -952,9 +953,9 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) HANDLE fh = 0; access_mode access = ACCESS_DEFAULT; DWORD flProtect, dwDesiredAccess; - char *keywords[] = { "fileno", "length", - "tagname", - "access", NULL }; + static const char *keywords[] = { "fileno", "length", + "tagname", + "access", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|zi", keywords, &fileno, &map_size_obj, diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index 12226a4..e788fc9 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -158,7 +158,7 @@ typedef struct { static void parser_free(PyST_Object *st); static int parser_compare(PyST_Object *left, PyST_Object *right); -static PyObject *parser_getattr(PyObject *self, char *name); +static PyObject *parser_getattr(PyObject *self, const char *name); static @@ -292,7 +292,7 @@ parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw) PyObject *res = 0; int ok; - static char *keywords[] = {"ast", "line_info", NULL}; + static const char *keywords[] = {"ast", "line_info", NULL}; if (self == NULL) { ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O:st2tuple", keywords, @@ -330,7 +330,7 @@ parser_st2list(PyST_Object *self, PyObject *args, PyObject *kw) PyObject *res = 0; int ok; - static char *keywords[] = {"ast", "line_info", NULL}; + static const char *keywords[] = {"ast", "line_info", NULL}; if (self == NULL) ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O:st2list", keywords, @@ -367,7 +367,7 @@ parser_compilest(PyST_Object *self, PyObject *args, PyObject *kw) char* str = "<syntax-tree>"; int ok; - static char *keywords[] = {"ast", "filename", NULL}; + static const char *keywords[] = {"ast", "filename", NULL}; if (self == NULL) ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|s:compilest", keywords, @@ -396,7 +396,7 @@ parser_isexpr(PyST_Object *self, PyObject *args, PyObject *kw) PyObject* res = 0; int ok; - static char *keywords[] = {"ast", NULL}; + static const char *keywords[] = {"ast", NULL}; if (self == NULL) ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:isexpr", keywords, @@ -419,7 +419,7 @@ parser_issuite(PyST_Object *self, PyObject *args, PyObject *kw) PyObject* res = 0; int ok; - static char *keywords[] = {"ast", NULL}; + static const char *keywords[] = {"ast", NULL}; if (self == NULL) ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:issuite", keywords, @@ -456,7 +456,7 @@ parser_methods[] = { static PyObject* -parser_getattr(PyObject *self, char *name) +parser_getattr(PyObject *self, const char *name) { return (Py_FindMethod(parser_methods, self, name)); } @@ -486,7 +486,7 @@ parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type) char* string = 0; PyObject* res = 0; - static char *keywords[] = {"source", NULL}; + static const char *keywords[] = {"source", NULL}; if (PyArg_ParseTupleAndKeywords(args, kw, argspec, keywords, &string)) { node* n = PyParser_SimpleParseString(string, @@ -568,7 +568,7 @@ parser_tuple2st(PyST_Object *self, PyObject *args, PyObject *kw) PyObject *tuple; node *tree; - static char *keywords[] = {"sequence", NULL}; + static const char *keywords[] = {"sequence", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kw, "O:sequence2st", keywords, &tuple)) diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index c853160..d1def24 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1724,8 +1724,8 @@ pyexpat_ParserCreate(PyObject *notused, PyObject *args, PyObject *kw) PyObject *intern = NULL; PyObject *result; int intern_decref = 0; - static char *kwlist[] = {"encoding", "namespace_separator", - "intern", NULL}; + static const char *kwlist[] = {"encoding", "namespace_separator", + "intern", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kw, "|zzO:ParserCreate", kwlist, &encoding, &namespace_separator, &intern)) diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 8da36b7..b40bb70 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -624,7 +624,7 @@ PyDoc_STRVAR(SHA256_new__doc__, static PyObject * SHA256_new(PyObject *self, PyObject *args, PyObject *kwdict) { - static char *kwlist[] = {"string", NULL}; + static const char *kwlist[] = {"string", NULL}; SHAobject *new; unsigned char *cp = NULL; int len; @@ -655,7 +655,7 @@ PyDoc_STRVAR(SHA224_new__doc__, static PyObject * SHA224_new(PyObject *self, PyObject *args, PyObject *kwdict) { - static char *kwlist[] = {"string", NULL}; + static const char *kwlist[] = {"string", NULL}; SHAobject *new; unsigned char *cp = NULL; int len; diff --git a/Modules/sha512module.c b/Modules/sha512module.c index d229625..57e9bc9 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -690,7 +690,7 @@ PyDoc_STRVAR(SHA512_new__doc__, static PyObject * SHA512_new(PyObject *self, PyObject *args, PyObject *kwdict) { - static char *kwlist[] = {"string", NULL}; + static const char *kwlist[] = {"string", NULL}; SHAobject *new; unsigned char *cp = NULL; int len; @@ -721,7 +721,7 @@ PyDoc_STRVAR(SHA384_new__doc__, static PyObject * SHA384_new(PyObject *self, PyObject *args, PyObject *kwdict) { - static char *kwlist[] = {"string", NULL}; + static const char *kwlist[] = {"string", NULL}; SHAobject *new; unsigned char *cp = NULL; int len; diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index e3573e3..3391405 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2489,7 +2489,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds) PySocketSockObject *s = (PySocketSockObject *)self; SOCKET_T fd; int family = AF_INET, type = SOCK_STREAM, proto = 0; - static char *keywords[] = {"family", "type", "proto", 0}; + static const char *keywords[] = {"family", "type", "proto", 0}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iii:socket", keywords, |