Skip to content

Commit

Permalink
Issue #1772673: The type of char* arguments now changed to `const c…
Browse files Browse the repository at this point in the history
…har*`.
  • Loading branch information
serhiy-storchaka committed Oct 19, 2013
1 parent 1a64cab commit 74dc84d
Show file tree
Hide file tree
Showing 39 changed files with 148 additions and 137 deletions.
2 changes: 1 addition & 1 deletion Doc/c-api/dict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Dictionary Objects
on failure.
.. c:function:: int PyDict_DelItemString(PyObject *p, char *key)
.. c:function:: int PyDict_DelItemString(PyObject *p, const char *key)
Remove the entry in dictionary *p* which has a key specified by the string
*key*. Return ``0`` on success or ``-1`` on failure.
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ error reporting in the interpreter; third-party code is advised to access
the :mod:`io` APIs instead.


.. c:function:: PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding, char *errors, char *newline, int closefd)
.. c:function:: PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding, const char *errors, const char *newline, int closefd)
Create a Python file object from the file descriptor of an already
opened file *fd*. The arguments *name*, *encoding*, *errors* and *newline*
Expand Down
8 changes: 4 additions & 4 deletions Doc/c-api/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Importing Modules
encoded string instead of a Unicode object.
.. c:function:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
.. index:: builtin: compile
Expand All @@ -145,7 +145,7 @@ Importing Modules
:c:func:`PyImport_ExecCodeModuleWithPathnames`.
.. c:function:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
.. c:function:: PyObject* PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of
the module object is set to *pathname* if it is non-``NULL``.
Expand All @@ -162,7 +162,7 @@ Importing Modules
.. versionadded:: 3.3
.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(char *name, PyObject *co, char *pathname, char *cpathname)
.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, const char *pathname, const char *cpathname)
Like :c:func:`PyImport_ExecCodeModuleObject`, but *name*, *pathname* and
*cpathname* are UTF-8 encoded strings. Attempts are also made to figure out
Expand Down Expand Up @@ -246,7 +246,7 @@ Importing Modules
.. versionadded:: 3.3
.. c:function:: int PyImport_ImportFrozenModule(char *name)
.. c:function:: int PyImport_ImportFrozenModule(const char *name)
Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a
UTF-8 encoded string instead of a Unicode object.
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
*NULL* on failure.
.. c:function:: PyObject* PyLong_FromString(char *str, char **pend, int base)
.. c:function:: PyObject* PyLong_FromString(const char *str, char **pend, int base)
Return a new :c:type:`PyLongObject` based on the string value in *str*, which
is interpreted according to the radix in *base*. If *pend* is non-*NULL*,
Expand Down
6 changes: 3 additions & 3 deletions Doc/c-api/mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Mapping Protocol
expression ``len(o)``.
.. c:function:: int PyMapping_DelItemString(PyObject *o, char *key)
.. c:function:: int PyMapping_DelItemString(PyObject *o, const char *key)
Remove the mapping for object *key* from the object *o*. Return ``-1`` on
failure. This is equivalent to the Python statement ``del o[key]``.
Expand Down Expand Up @@ -67,13 +67,13 @@ Mapping Protocol
the Python expression ``list(o.items())``.
.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, char *key)
.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, const char *key)
Return element of *o* corresponding to the object *key* or *NULL* on failure.
This is the equivalent of the Python expression ``o[key]``.
.. c:function:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v)
.. c:function:: int PyMapping_SetItemString(PyObject *o, const char *key, PyObject *v)
Map the object *key* to the value *v* in object *o*. Returns ``-1`` on failure.
This is the equivalent of the Python statement ``o[key] = v``.
2 changes: 1 addition & 1 deletion Doc/c-api/veryhigh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ the same library that the Python runtime is using.
Python source code.
.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *)
.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *)
Can be set to point to a function with the prototype
``char *func(FILE *stdin, FILE *stdout, char *prompt)``,
Expand Down
18 changes: 9 additions & 9 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,13 @@ PyImport_AddModule:const char*:name::
PyImport_Cleanup:void:::

PyImport_ExecCodeModule:PyObject*::+1:
PyImport_ExecCodeModule:char*:name::
PyImport_ExecCodeModule:const char*:name::
PyImport_ExecCodeModule:PyObject*:co:0:

PyImport_ExecCodeModuleEx:PyObject*::+1:
PyImport_ExecCodeModuleEx:char*:name::
PyImport_ExecCodeModuleEx:const char*:name::
PyImport_ExecCodeModuleEx:PyObject*:co:0:
PyImport_ExecCodeModuleEx:char*:pathname::
PyImport_ExecCodeModuleEx:const char*:pathname::

PyImport_GetMagicNumber:long:::

Expand All @@ -524,7 +524,7 @@ PyImport_Import:PyObject*::+1:
PyImport_Import:PyObject*:name:0:

PyImport_ImportFrozenModule:int:::
PyImport_ImportFrozenModule:char*:::
PyImport_ImportFrozenModule:const char*:::

PyImport_ImportModule:PyObject*::+1:
PyImport_ImportModule:const char*:name::
Expand Down Expand Up @@ -673,7 +673,7 @@ PyLong_FromUnsignedLongLong:PyObject*::+1:
PyLong_FromUnsignedLongLong:unsigned long long:v::

PyLong_FromString:PyObject*::+1:
PyLong_FromString:char*:str::
PyLong_FromString:const char*:str::
PyLong_FromString:char**:pend::
PyLong_FromString:int:base::

Expand Down Expand Up @@ -701,15 +701,15 @@ PyMapping_DelItemString:const char*:key::

PyMapping_GetItemString:PyObject*::+1:
PyMapping_GetItemString:PyObject*:o:0:
PyMapping_GetItemString:char*:key::
PyMapping_GetItemString:const char*:key::

PyMapping_HasKey:int:::
PyMapping_HasKey:PyObject*:o:0:
PyMapping_HasKey:PyObject*:key::

PyMapping_HasKeyString:int:::
PyMapping_HasKeyString:PyObject*:o:0:
PyMapping_HasKeyString:char*:key::
PyMapping_HasKeyString:const char*:key::

PyMapping_Items:PyObject*::+1:
PyMapping_Items:PyObject*:o:0:
Expand All @@ -722,7 +722,7 @@ PyMapping_Length:PyObject*:o:0:

PyMapping_SetItemString:int:::
PyMapping_SetItemString:PyObject*:o:0:
PyMapping_SetItemString:char*:key::
PyMapping_SetItemString:const char*:key::
PyMapping_SetItemString:PyObject*:v:+1:

PyMapping_Values:PyObject*::+1:
Expand All @@ -735,7 +735,7 @@ PyMarshal_ReadObjectFromFile:PyObject*::+1:
PyMarshal_ReadObjectFromFile:FILE*:file::

PyMarshal_ReadObjectFromString:PyObject*::+1:
PyMarshal_ReadObjectFromString:char*:string::
PyMarshal_ReadObjectFromString:const char*:string::
PyMarshal_ReadObjectFromString:int:len::

PyMarshal_WriteObjectToString:PyObject*::+1:
Expand Down
19 changes: 10 additions & 9 deletions Include/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

/* Implemented elsewhere:
int PyObject_HasAttrString(PyObject *o, char *attr_name);
int PyObject_HasAttrString(PyObject *o, const char *attr_name);
Returns 1 if o has the attribute attr_name, and 0 otherwise.
This is equivalent to the Python expression:
Expand All @@ -156,7 +156,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

/* Implemented elsewhere:
PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name);
PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name);
Retrieve an attributed named attr_name form object o.
Returns the attribute value on success, or NULL on failure.
Expand Down Expand Up @@ -189,7 +189,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

/* Implemented elsewhere:
int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v);
int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v);
Set the value of the attribute named attr_name, for object o,
to the value, v. Returns -1 on failure. This is
Expand All @@ -209,7 +209,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

/* implemented as a macro:
int PyObject_DelAttrString(PyObject *o, char *attr_name);
int PyObject_DelAttrString(PyObject *o, const char *attr_name);
Delete attribute named attr_name, for object o. Returns
-1 on failure. This is the equivalent of the Python
Expand Down Expand Up @@ -434,7 +434,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
statement: o[key]=v.
*/

PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key);
PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key);

/*
Remove the mapping for object, key, from the object *o.
Expand Down Expand Up @@ -1156,7 +1156,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);

/* implemented as a macro:
int PyMapping_DelItemString(PyObject *o, char *key);
int PyMapping_DelItemString(PyObject *o, const char *key);
Remove the mapping for object, key, from the object *o.
Returns -1 on failure. This is equivalent to
Expand All @@ -1174,7 +1174,7 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
*/
#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K))

PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key);
PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key);

/*
On success, return 1 if the mapping object has the key, key,
Expand Down Expand Up @@ -1218,15 +1218,16 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
*/

PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key);
PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o,
const char *key);

/*
Return element of o corresponding to the object, key, or NULL
on failure. This is the equivalent of the Python expression:
o[key].
*/

PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key,
PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key,
PyObject *value);

/*
Expand Down
5 changes: 3 additions & 2 deletions Include/fileobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ extern "C" {

#define PY_STDIOTEXTMODE "b"

PyAPI_FUNC(PyObject *) PyFile_FromFd(int, char *, char *, int, char *, char *,
char *, int);
PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int,
const char *, const char *,
const char *, int);
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
Expand Down
6 changes: 3 additions & 3 deletions Include/grammar.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ typedef struct {
/* FUNCTIONS */

grammar *newgrammar(int start);
dfa *adddfa(grammar *g, int type, char *name);
dfa *adddfa(grammar *g, int type, const char *name);
int addstate(dfa *d);
void addarc(dfa *d, int from, int to, int lbl);
dfa *PyGrammar_FindDFA(grammar *g, int type);

int addlabel(labellist *ll, int type, char *str);
int findlabel(labellist *ll, int type, char *str);
int addlabel(labellist *ll, int type, const char *str);
int findlabel(labellist *ll, int type, const char *str);
const char *PyGrammar_LabelRepr(label *lb);
void translatelabels(grammar *g);

Expand Down
18 changes: 9 additions & 9 deletions Include/import.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ PyMODINIT_FUNC PyInit_imp(void);
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
char *name, /* UTF-8 encoded string */
const char *name, /* UTF-8 encoded string */
PyObject *co
);
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
char *name, /* UTF-8 encoded string */
const char *name, /* UTF-8 encoded string */
PyObject *co,
char *pathname /* decoded from the filesystem encoding */
const char *pathname /* decoded from the filesystem encoding */
);
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
char *name, /* UTF-8 encoded string */
const char *name, /* UTF-8 encoded string */
PyObject *co,
char *pathname, /* decoded from the filesystem encoding */
char *cpathname /* decoded from the filesystem encoding */
const char *pathname, /* decoded from the filesystem encoding */
const char *cpathname /* decoded from the filesystem encoding */
);
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
PyObject *name,
Expand Down Expand Up @@ -72,7 +72,7 @@ PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
PyObject *name
);
PyAPI_FUNC(int) PyImport_ImportFrozenModule(
char *name /* UTF-8 encoded string */
const char *name /* UTF-8 encoded string */
);

#ifndef Py_LIMITED_API
Expand All @@ -92,12 +92,12 @@ PyAPI_FUNC(PyObject *)_PyImport_FindBuiltin(
PyAPI_FUNC(PyObject *)_PyImport_FindExtensionObject(PyObject *, PyObject *);
PyAPI_FUNC(int)_PyImport_FixupBuiltin(
PyObject *mod,
char *name /* UTF-8 encoded string */
const char *name /* UTF-8 encoded string */
);
PyAPI_FUNC(int)_PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);

struct _inittab {
char *name; /* ASCII encoded string */
const char *name; /* ASCII encoded string */
PyObject* (*initfunc)(void);
};
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
Expand Down
6 changes: 3 additions & 3 deletions Include/longobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
#endif /* HAVE_LONG_LONG */

PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
#ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
Expand Down Expand Up @@ -189,8 +189,8 @@ PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter(
/* These aren't really part of the int object, but they're handy. The
functions are in Python/mystrtoul.c.
*/
PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int);
PyAPI_FUNC(long) PyOS_strtol(char *, char **, int);
PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);

#ifdef __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion Include/marshal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
#endif
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *,
Py_ssize_t);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 74dc84d

Please sign in to comment.