Skip to content

Commit a5552f0

Browse files
bpo-32240: Add the const qualifier to declarations of PyObject* array arguments. (#4746)
1 parent 3325a67 commit a5552f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+669
-662
lines changed

Doc/c-api/veryhigh.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ the same library that the Python runtime is using.
301301
set to *NULL*.
302302
303303
304-
.. c:function:: PyObject* PyEval_EvalCodeEx(PyObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *kwdefs, PyObject *closure)
304+
.. c:function:: PyObject* PyEval_EvalCodeEx(PyObject *co, PyObject *globals, PyObject *locals, PyObject *const *args, int argcount, PyObject *const *kws, int kwcount, PyObject *const *defs, int defcount, PyObject *kwdefs, PyObject *closure)
305305
306306
Evaluate a precompiled code object, given a particular environment for its
307307
evaluation. This environment consists of a dictionary of global variables,

Include/abstract.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable,
157157

158158
#ifndef Py_LIMITED_API
159159
PyAPI_FUNC(PyObject*) _PyStack_AsTuple(
160-
PyObject **stack,
160+
PyObject *const *stack,
161161
Py_ssize_t nargs);
162162

163163
PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
164-
PyObject **stack,
164+
PyObject *const *stack,
165165
Py_ssize_t nargs,
166166
Py_ssize_t start,
167167
Py_ssize_t end);
@@ -177,7 +177,7 @@ PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
177177
an exception, the caller is responsible to implement an explicit keys on
178178
kwnames. */
179179
PyAPI_FUNC(PyObject *) _PyStack_AsDict(
180-
PyObject **values,
180+
PyObject *const *values,
181181
PyObject *kwnames);
182182

183183
/* Convert (args, nargs, kwargs: dict) into a (stack, nargs, kwnames: tuple).
@@ -192,10 +192,10 @@ PyAPI_FUNC(PyObject *) _PyStack_AsDict(
192192
The type of keyword keys is not checked, these checks should be done
193193
later (ex: _PyArg_ParseStackAndKeywords). */
194194
PyAPI_FUNC(int) _PyStack_UnpackDict(
195-
PyObject **args,
195+
PyObject *const *args,
196196
Py_ssize_t nargs,
197197
PyObject *kwargs,
198-
PyObject ***p_stack,
198+
PyObject *const **p_stack,
199199
PyObject **p_kwnames);
200200

201201
/* Suggested size (number of positional arguments) for arrays of PyObject*
@@ -224,7 +224,7 @@ PyAPI_FUNC(int) _PyObject_HasFastCall(PyObject *callable);
224224
error. */
225225
PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
226226
PyObject *callable,
227-
PyObject **args,
227+
PyObject *const *args,
228228
Py_ssize_t nargs,
229229
PyObject *kwargs);
230230

@@ -245,7 +245,7 @@ PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
245245
error. */
246246
PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords(
247247
PyObject *callable,
248-
PyObject **args,
248+
PyObject *const *args,
249249
Py_ssize_t nargs,
250250
PyObject *kwnames);
251251

@@ -264,7 +264,7 @@ PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
264264
PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(
265265
PyObject *callable,
266266
PyObject *obj,
267-
PyObject **args,
267+
PyObject *const *args,
268268
Py_ssize_t nargs);
269269

270270
PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable,

Include/descrobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
9292
#ifndef Py_LIMITED_API
9393

9494
PyAPI_FUNC(PyObject *) _PyMethodDescr_FastCallKeywords(
95-
PyObject *descrobj, PyObject **stack, Py_ssize_t nargs, PyObject *kwnames);
95+
PyObject *descrobj, PyObject *const *stack, Py_ssize_t nargs, PyObject *kwnames);
9696
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
9797
struct wrapperbase *, void *);
9898
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)

Include/eval.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
1212
PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
1313
PyObject *globals,
1414
PyObject *locals,
15-
PyObject **args, int argc,
16-
PyObject **kwds, int kwdc,
17-
PyObject **defs, int defc,
15+
PyObject *const *args, int argc,
16+
PyObject *const *kwds, int kwdc,
17+
PyObject *const *defs, int defc,
1818
PyObject *kwdefs, PyObject *closure);
1919

2020
#ifndef Py_LIMITED_API
2121
PyAPI_FUNC(PyObject *) _PyEval_EvalCodeWithName(
2222
PyObject *co,
2323
PyObject *globals, PyObject *locals,
24-
PyObject **args, Py_ssize_t argcount,
25-
PyObject **kwnames, PyObject **kwargs,
24+
PyObject *const *args, Py_ssize_t argcount,
25+
PyObject *const *kwnames, PyObject *const *kwargs,
2626
Py_ssize_t kwcount, int kwstep,
27-
PyObject **defs, Py_ssize_t defcount,
27+
PyObject *const *defs, Py_ssize_t defcount,
2828
PyObject *kwdefs, PyObject *closure,
2929
PyObject *name, PyObject *qualname);
3030

Include/funcobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *);
6161
#ifndef Py_LIMITED_API
6262
PyAPI_FUNC(PyObject *) _PyFunction_FastCallDict(
6363
PyObject *func,
64-
PyObject **args,
64+
PyObject *const *args,
6565
Py_ssize_t nargs,
6666
PyObject *kwargs);
6767

6868
PyAPI_FUNC(PyObject *) _PyFunction_FastCallKeywords(
6969
PyObject *func,
70-
PyObject **stack,
70+
PyObject *const *stack,
7171
Py_ssize_t nargs,
7272
PyObject *kwnames);
7373
#endif

Include/methodobject.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ PyAPI_DATA(PyTypeObject) PyCFunction_Type;
1616
#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type)
1717

1818
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
19-
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject **, Py_ssize_t);
19+
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t);
2020
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
2121
PyObject *);
2222
typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *,
23-
PyObject **, Py_ssize_t,
23+
PyObject *const *, Py_ssize_t,
2424
PyObject *);
2525
typedef PyObject *(*PyNoArgsFunction)(PyObject *);
2626

@@ -43,12 +43,12 @@ PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
4343

4444
#ifndef Py_LIMITED_API
4545
PyAPI_FUNC(PyObject *) _PyCFunction_FastCallDict(PyObject *func,
46-
PyObject **args,
46+
PyObject *const *args,
4747
Py_ssize_t nargs,
4848
PyObject *kwargs);
4949

5050
PyAPI_FUNC(PyObject *) _PyCFunction_FastCallKeywords(PyObject *func,
51-
PyObject **stack,
51+
PyObject *const *stack,
5252
Py_ssize_t nargs,
5353
PyObject *kwnames);
5454
#endif
@@ -110,14 +110,14 @@ typedef struct {
110110
PyAPI_FUNC(PyObject *) _PyMethodDef_RawFastCallDict(
111111
PyMethodDef *method,
112112
PyObject *self,
113-
PyObject **args,
113+
PyObject *const *args,
114114
Py_ssize_t nargs,
115115
PyObject *kwargs);
116116

117117
PyAPI_FUNC(PyObject *) _PyMethodDef_RawFastCallKeywords(
118118
PyMethodDef *method,
119119
PyObject *self,
120-
PyObject **args,
120+
PyObject *const *args,
121121
Py_ssize_t nargs,
122122
PyObject *kwnames);
123123
#endif

Include/modsupport.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
5252

5353
#ifndef Py_LIMITED_API
5454
PyAPI_FUNC(int) _PyArg_UnpackStack(
55-
PyObject **args,
55+
PyObject *const *args,
5656
Py_ssize_t nargs,
5757
const char *name,
5858
Py_ssize_t min,
@@ -99,12 +99,12 @@ typedef struct _PyArg_Parser {
9999
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
100100
struct _PyArg_Parser *, ...);
101101
PyAPI_FUNC(int) _PyArg_ParseStack(
102-
PyObject **args,
102+
PyObject *const *args,
103103
Py_ssize_t nargs,
104104
const char *format,
105105
...);
106106
PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
107-
PyObject **args,
107+
PyObject *const *args,
108108
Py_ssize_t nargs,
109109
PyObject *kwnames,
110110
struct _PyArg_Parser *,

Include/unicodeobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_Join(
19791979
#ifndef Py_LIMITED_API
19801980
PyAPI_FUNC(PyObject *) _PyUnicode_JoinArray(
19811981
PyObject *separator,
1982-
PyObject **items,
1982+
PyObject *const *items,
19831983
Py_ssize_t seqlen
19841984
);
19851985
#endif /* Py_LIMITED_API */

Modules/_collectionsmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n)
912912
}
913913

914914
static PyObject *
915-
deque_rotate(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
915+
deque_rotate(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
916916
{
917917
Py_ssize_t n=1;
918918

@@ -1045,7 +1045,7 @@ deque_len(dequeobject *deque)
10451045
}
10461046

10471047
static PyObject *
1048-
deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
1048+
deque_index(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
10491049
{
10501050
Py_ssize_t i, n, start=0, stop=Py_SIZE(deque);
10511051
PyObject *v, *item;
@@ -1122,7 +1122,7 @@ PyDoc_STRVAR(index_doc,
11221122
*/
11231123

11241124
static PyObject *
1125-
deque_insert(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
1125+
deque_insert(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
11261126
{
11271127
Py_ssize_t index;
11281128
Py_ssize_t n = Py_SIZE(deque);

Modules/_elementtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2771,7 +2771,7 @@ typedef struct {
27712771
} XMLParserObject;
27722772

27732773
static PyObject*
2774-
_elementtree_XMLParser_doctype(XMLParserObject *self, PyObject **args, Py_ssize_t nargs);
2774+
_elementtree_XMLParser_doctype(XMLParserObject *self, PyObject *const *args, Py_ssize_t nargs);
27752775
static PyObject *
27762776
_elementtree_XMLParser_doctype_impl(XMLParserObject *self, PyObject *name,
27772777
PyObject *pubid, PyObject *system);

0 commit comments

Comments
 (0)