]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Add const to several API functions that take char *.
authorJeremy Hylton <jeremy@alum.mit.edu>
Sat, 10 Dec 2005 18:50:16 +0000 (18:50 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Sat, 10 Dec 2005 18:50:16 +0000 (18:50 +0000)
commitaf68c874a6803b4e90b616077a602c0593719a1d
treec7361b29cf629171b4da8e51cfd1074f67d814a7
parentaaa2f1dea706daf2a5f431d97a3e3120dba652d2
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 *.
52 files changed:
Include/cStringIO.h
Include/ceval.h
Include/import.h
Include/methodobject.h
Include/modsupport.h
Include/moduleobject.h
Include/object.h
Modules/_bisectmodule.c
Modules/_bsddb.c
Modules/_csv.c
Modules/_cursesmodule.c
Modules/_hashopenssl.c
Modules/_sre.c
Modules/_tkinter.c
Modules/binascii.c
Modules/bz2module.c
Modules/cPickle.c
Modules/cStringIO.c
Modules/cjkcodecs/multibytecodec.c
Modules/datetimemodule.c
Modules/itertoolsmodule.c
Modules/mmapmodule.c
Modules/parsermodule.c
Modules/pyexpat.c
Modules/sha256module.c
Modules/sha512module.c
Modules/socketmodule.c
Objects/boolobject.c
Objects/classobject.c
Objects/complexobject.c
Objects/descrobject.c
Objects/enumobject.c
Objects/fileobject.c
Objects/floatobject.c
Objects/funcobject.c
Objects/intobject.c
Objects/listobject.c
Objects/longobject.c
Objects/methodobject.c
Objects/moduleobject.c
Objects/object.c
Objects/stringobject.c
Objects/structseq.c
Objects/tupleobject.c
Objects/typeobject.c
Objects/unicodeobject.c
Objects/weakrefobject.c
Python/bltinmodule.c
Python/ceval.c
Python/getargs.c
Python/import.c
Python/modsupport.c