Skip to content

Commit c679227

Browse files
Issue #1772673: The type of char* arguments now changed to const char*.
1 parent 80ab130 commit c679227

39 files changed

+148
-137
lines changed

Doc/c-api/dict.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Dictionary Objects
8484
on failure.
8585
8686
87-
.. c:function:: int PyDict_DelItemString(PyObject *p, char *key)
87+
.. c:function:: int PyDict_DelItemString(PyObject *p, const char *key)
8888
8989
Remove the entry in dictionary *p* which has a key specified by the string
9090
*key*. Return ``0`` on success or ``-1`` on failure.

Doc/c-api/file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error reporting in the interpreter; third-party code is advised to access
1717
the :mod:`io` APIs instead.
1818

1919

20-
.. c:function:: PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding, char *errors, char *newline, int closefd)
20+
.. 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)
2121
2222
Create a Python file object from the file descriptor of an already
2323
opened file *fd*. The arguments *name*, *encoding*, *errors* and *newline*

Doc/c-api/import.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Importing Modules
118118
encoded string instead of a Unicode object.
119119
120120
121-
.. c:function:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
121+
.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
122122
123123
.. index:: builtin: compile
124124
@@ -145,7 +145,7 @@ Importing Modules
145145
:c:func:`PyImport_ExecCodeModuleWithPathnames`.
146146
147147
148-
.. c:function:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
148+
.. c:function:: PyObject* PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
149149
150150
Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of
151151
the module object is set to *pathname* if it is non-``NULL``.
@@ -162,7 +162,7 @@ Importing Modules
162162
.. versionadded:: 3.3
163163
164164
165-
.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(char *name, PyObject *co, char *pathname, char *cpathname)
165+
.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, const char *pathname, const char *cpathname)
166166
167167
Like :c:func:`PyImport_ExecCodeModuleObject`, but *name*, *pathname* and
168168
*cpathname* are UTF-8 encoded strings. Attempts are also made to figure out
@@ -246,7 +246,7 @@ Importing Modules
246246
.. versionadded:: 3.3
247247
248248
249-
.. c:function:: int PyImport_ImportFrozenModule(char *name)
249+
.. c:function:: int PyImport_ImportFrozenModule(const char *name)
250250
251251
Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a
252252
UTF-8 encoded string instead of a Unicode object.

Doc/c-api/long.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
8080
*NULL* on failure.
8181
8282
83-
.. c:function:: PyObject* PyLong_FromString(char *str, char **pend, int base)
83+
.. c:function:: PyObject* PyLong_FromString(const char *str, char **pend, int base)
8484
8585
Return a new :c:type:`PyLongObject` based on the string value in *str*, which
8686
is interpreted according to the radix in *base*. If *pend* is non-*NULL*,

Doc/c-api/mapping.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Mapping Protocol
2222
expression ``len(o)``.
2323
2424
25-
.. c:function:: int PyMapping_DelItemString(PyObject *o, char *key)
25+
.. c:function:: int PyMapping_DelItemString(PyObject *o, const char *key)
2626
2727
Remove the mapping for object *key* from the object *o*. Return ``-1`` on
2828
failure. This is equivalent to the Python statement ``del o[key]``.
@@ -67,13 +67,13 @@ Mapping Protocol
6767
the Python expression ``list(o.items())``.
6868
6969
70-
.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, char *key)
70+
.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, const char *key)
7171
7272
Return element of *o* corresponding to the object *key* or *NULL* on failure.
7373
This is the equivalent of the Python expression ``o[key]``.
7474
7575
76-
.. c:function:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v)
76+
.. c:function:: int PyMapping_SetItemString(PyObject *o, const char *key, PyObject *v)
7777
7878
Map the object *key* to the value *v* in object *o*. Returns ``-1`` on failure.
7979
This is the equivalent of the Python statement ``o[key] = v``.

Doc/c-api/veryhigh.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ the same library that the Python runtime is using.
155155
Python source code.
156156
157157
158-
.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *)
158+
.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *)
159159
160160
Can be set to point to a function with the prototype
161161
``char *func(FILE *stdin, FILE *stdout, char *prompt)``,

Doc/data/refcounts.dat

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,13 @@ PyImport_AddModule:const char*:name::
508508
PyImport_Cleanup:void:::
509509

510510
PyImport_ExecCodeModule:PyObject*::+1:
511-
PyImport_ExecCodeModule:char*:name::
511+
PyImport_ExecCodeModule:const char*:name::
512512
PyImport_ExecCodeModule:PyObject*:co:0:
513513

514514
PyImport_ExecCodeModuleEx:PyObject*::+1:
515-
PyImport_ExecCodeModuleEx:char*:name::
515+
PyImport_ExecCodeModuleEx:const char*:name::
516516
PyImport_ExecCodeModuleEx:PyObject*:co:0:
517-
PyImport_ExecCodeModuleEx:char*:pathname::
517+
PyImport_ExecCodeModuleEx:const char*:pathname::
518518

519519
PyImport_GetMagicNumber:long:::
520520

@@ -524,7 +524,7 @@ PyImport_Import:PyObject*::+1:
524524
PyImport_Import:PyObject*:name:0:
525525

526526
PyImport_ImportFrozenModule:int:::
527-
PyImport_ImportFrozenModule:char*:::
527+
PyImport_ImportFrozenModule:const char*:::
528528

529529
PyImport_ImportModule:PyObject*::+1:
530530
PyImport_ImportModule:const char*:name::
@@ -673,7 +673,7 @@ PyLong_FromUnsignedLongLong:PyObject*::+1:
673673
PyLong_FromUnsignedLongLong:unsigned long long:v::
674674

675675
PyLong_FromString:PyObject*::+1:
676-
PyLong_FromString:char*:str::
676+
PyLong_FromString:const char*:str::
677677
PyLong_FromString:char**:pend::
678678
PyLong_FromString:int:base::
679679

@@ -701,15 +701,15 @@ PyMapping_DelItemString:const char*:key::
701701

702702
PyMapping_GetItemString:PyObject*::+1:
703703
PyMapping_GetItemString:PyObject*:o:0:
704-
PyMapping_GetItemString:char*:key::
704+
PyMapping_GetItemString:const char*:key::
705705

706706
PyMapping_HasKey:int:::
707707
PyMapping_HasKey:PyObject*:o:0:
708708
PyMapping_HasKey:PyObject*:key::
709709

710710
PyMapping_HasKeyString:int:::
711711
PyMapping_HasKeyString:PyObject*:o:0:
712-
PyMapping_HasKeyString:char*:key::
712+
PyMapping_HasKeyString:const char*:key::
713713

714714
PyMapping_Items:PyObject*::+1:
715715
PyMapping_Items:PyObject*:o:0:
@@ -722,7 +722,7 @@ PyMapping_Length:PyObject*:o:0:
722722

723723
PyMapping_SetItemString:int:::
724724
PyMapping_SetItemString:PyObject*:o:0:
725-
PyMapping_SetItemString:char*:key::
725+
PyMapping_SetItemString:const char*:key::
726726
PyMapping_SetItemString:PyObject*:v:+1:
727727

728728
PyMapping_Values:PyObject*::+1:
@@ -735,7 +735,7 @@ PyMarshal_ReadObjectFromFile:PyObject*::+1:
735735
PyMarshal_ReadObjectFromFile:FILE*:file::
736736

737737
PyMarshal_ReadObjectFromString:PyObject*::+1:
738-
PyMarshal_ReadObjectFromString:char*:string::
738+
PyMarshal_ReadObjectFromString:const char*:string::
739739
PyMarshal_ReadObjectFromString:int:len::
740740

741741
PyMarshal_WriteObjectToString:PyObject*::+1:

Include/abstract.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
144144

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

157157
/* Implemented elsewhere:
158158
159-
PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name);
159+
PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name);
160160
161161
Retrieve an attributed named attr_name form object o.
162162
Returns the attribute value on success, or NULL on failure.
@@ -189,7 +189,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
189189

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

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

437-
PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key);
437+
PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key);
438438

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

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

1177-
PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key);
1177+
PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key);
11781178

11791179
/*
11801180
On success, return 1 if the mapping object has the key, key,
@@ -1218,15 +1218,16 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
12181218
12191219
*/
12201220

1221-
PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key);
1221+
PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o,
1222+
const char *key);
12221223

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

1229-
PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key,
1230+
PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key,
12301231
PyObject *value);
12311232

12321233
/*

Include/fileobject.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ extern "C" {
88

99
#define PY_STDIOTEXTMODE "b"
1010

11-
PyAPI_FUNC(PyObject *) PyFile_FromFd(int, char *, char *, int, char *, char *,
12-
char *, int);
11+
PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int,
12+
const char *, const char *,
13+
const char *, int);
1314
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
1415
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
1516
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);

Include/grammar.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ typedef struct {
6969
/* FUNCTIONS */
7070

7171
grammar *newgrammar(int start);
72-
dfa *adddfa(grammar *g, int type, char *name);
72+
dfa *adddfa(grammar *g, int type, const char *name);
7373
int addstate(dfa *d);
7474
void addarc(dfa *d, int from, int to, int lbl);
7575
dfa *PyGrammar_FindDFA(grammar *g, int type);
7676

77-
int addlabel(labellist *ll, int type, char *str);
78-
int findlabel(labellist *ll, int type, char *str);
77+
int addlabel(labellist *ll, int type, const char *str);
78+
int findlabel(labellist *ll, int type, const char *str);
7979
const char *PyGrammar_LabelRepr(label *lb);
8080
void translatelabels(grammar *g);
8181

Include/import.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ PyMODINIT_FUNC PyInit_imp(void);
1313
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
1414
PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
1515
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
16-
char *name, /* UTF-8 encoded string */
16+
const char *name, /* UTF-8 encoded string */
1717
PyObject *co
1818
);
1919
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
20-
char *name, /* UTF-8 encoded string */
20+
const char *name, /* UTF-8 encoded string */
2121
PyObject *co,
22-
char *pathname /* decoded from the filesystem encoding */
22+
const char *pathname /* decoded from the filesystem encoding */
2323
);
2424
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
25-
char *name, /* UTF-8 encoded string */
25+
const char *name, /* UTF-8 encoded string */
2626
PyObject *co,
27-
char *pathname, /* decoded from the filesystem encoding */
28-
char *cpathname /* decoded from the filesystem encoding */
27+
const char *pathname, /* decoded from the filesystem encoding */
28+
const char *cpathname /* decoded from the filesystem encoding */
2929
);
3030
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
3131
PyObject *name,
@@ -72,7 +72,7 @@ PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
7272
PyObject *name
7373
);
7474
PyAPI_FUNC(int) PyImport_ImportFrozenModule(
75-
char *name /* UTF-8 encoded string */
75+
const char *name /* UTF-8 encoded string */
7676
);
7777

7878
#ifndef Py_LIMITED_API
@@ -92,12 +92,12 @@ PyAPI_FUNC(PyObject *)_PyImport_FindBuiltin(
9292
PyAPI_FUNC(PyObject *)_PyImport_FindExtensionObject(PyObject *, PyObject *);
9393
PyAPI_FUNC(int)_PyImport_FixupBuiltin(
9494
PyObject *mod,
95-
char *name /* UTF-8 encoded string */
95+
const char *name /* UTF-8 encoded string */
9696
);
9797
PyAPI_FUNC(int)_PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
9898

9999
struct _inittab {
100-
char *name; /* ASCII encoded string */
100+
const char *name; /* ASCII encoded string */
101101
PyObject* (*initfunc)(void);
102102
};
103103
PyAPI_DATA(struct _inittab *) PyImport_Inittab;

Include/longobject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
9393
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
9494
#endif /* HAVE_LONG_LONG */
9595

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

195195
#ifdef __cplusplus
196196
}

Include/marshal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
1919
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
2020
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
2121
#endif
22-
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
22+
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *,
23+
Py_ssize_t);
2324

2425
#ifdef __cplusplus
2526
}

0 commit comments

Comments
 (0)