summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-12-04 11:14:56 (GMT)
committerGitHub <noreply@github.com>2023-12-04 11:14:56 (GMT)
commitda6760bdf5ed8ede203618d5118f4ceb2cb1652d (patch)
treeb6ba925bc254f38e392ff77ca0530523ff8b7012 /Include
parentcda737924fd616c4e08027888258f97e81f34447 (diff)
downloadcpython-da6760bdf5ed8ede203618d5118f4ceb2cb1652d.zip
cpython-da6760bdf5ed8ede203618d5118f4ceb2cb1652d.tar.gz
cpython-da6760bdf5ed8ede203618d5118f4ceb2cb1652d.tar.bz2
gh-65210: Add const qualifiers in PyArg_VaParseTupleAndKeywords() (GH-105958)
Change the declaration of the keywords parameter in functions PyArg_ParseTupleAndKeywords() and PyArg_VaParseTupleAndKeywords() from `char **` to `char * const *` in C and `const char * const *` in C++. It makes these functions compatible with argument of type `const char * const *`, `const char **` or `char * const *` in C++ and `char * const *` in C without explicit type cast. Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Diffstat (limited to 'Include')
-rw-r--r--Include/modsupport.h4
-rw-r--r--Include/pyport.h8
2 files changed, 10 insertions, 2 deletions
diff --git a/Include/modsupport.h b/Include/modsupport.h
index 450cc99..ea4c0fc 100644
--- a/Include/modsupport.h
+++ b/Include/modsupport.h
@@ -9,10 +9,10 @@ extern "C" {
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
- const char *, char **, ...);
+ const char *, PY_CXX_CONST char * const *, ...);
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
- const char *, char **, va_list);
+ const char *, PY_CXX_CONST char * const *, va_list);
PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
diff --git a/Include/pyport.h b/Include/pyport.h
index abb526d..3284710 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -586,6 +586,14 @@ extern "C" {
# define ALIGNOF_MAX_ALIGN_T _Alignof(long double)
#endif
+#ifndef PY_CXX_CONST
+# ifdef __cplusplus
+# define PY_CXX_CONST const
+# else
+# define PY_CXX_CONST
+# endif
+#endif
+
#if defined(__sgi) && !defined(_SGI_MP_SOURCE)
# define _SGI_MP_SOURCE
#endif