mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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>
This commit is contained in:
parent
cda737924f
commit
da6760bdf5
7 changed files with 57 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
|||
|
||||
/* New getargs implementation */
|
||||
|
||||
#define PY_CXX_CONST const
|
||||
#include "Python.h"
|
||||
#include "pycore_abstract.h" // _PyNumber_Index()
|
||||
#include "pycore_dict.h" // _PyDict_HasOnlyStringKeys()
|
||||
|
@ -12,10 +13,10 @@
|
|||
PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
|
||||
PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
|
||||
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
|
||||
const char *, char **, ...);
|
||||
const char *, const char * const *, ...);
|
||||
PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
|
||||
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
|
||||
const char *, char **, va_list);
|
||||
const char *, const char * const *, va_list);
|
||||
|
||||
#define FLAG_COMPAT 1
|
||||
|
||||
|
@ -54,7 +55,7 @@ static Py_ssize_t convertbuffer(PyObject *, const void **p, const char **);
|
|||
static int getbuffer(PyObject *, Py_buffer *, const char**);
|
||||
|
||||
static int vgetargskeywords(PyObject *, PyObject *,
|
||||
const char *, char **, va_list *, int);
|
||||
const char *, const char * const *, va_list *, int);
|
||||
static int vgetargskeywordsfast(PyObject *, PyObject *,
|
||||
struct _PyArg_Parser *, va_list *, int);
|
||||
static int vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
|
||||
|
@ -1247,7 +1248,7 @@ int
|
|||
PyArg_ParseTupleAndKeywords(PyObject *args,
|
||||
PyObject *keywords,
|
||||
const char *format,
|
||||
char **kwlist, ...)
|
||||
const char * const *kwlist, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list va;
|
||||
|
@ -1271,7 +1272,7 @@ int
|
|||
_PyArg_ParseTupleAndKeywords_SizeT(PyObject *args,
|
||||
PyObject *keywords,
|
||||
const char *format,
|
||||
char **kwlist, ...)
|
||||
const char * const *kwlist, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list va;
|
||||
|
@ -1297,7 +1298,7 @@ int
|
|||
PyArg_VaParseTupleAndKeywords(PyObject *args,
|
||||
PyObject *keywords,
|
||||
const char *format,
|
||||
char **kwlist, va_list va)
|
||||
const char * const *kwlist, va_list va)
|
||||
{
|
||||
int retval;
|
||||
va_list lva;
|
||||
|
@ -1322,7 +1323,7 @@ int
|
|||
_PyArg_VaParseTupleAndKeywords_SizeT(PyObject *args,
|
||||
PyObject *keywords,
|
||||
const char *format,
|
||||
char **kwlist, va_list va)
|
||||
const char * const *kwlist, va_list va)
|
||||
{
|
||||
int retval;
|
||||
va_list lva;
|
||||
|
@ -1460,7 +1461,7 @@ PyArg_ValidateKeywordArguments(PyObject *kwargs)
|
|||
|
||||
static int
|
||||
vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
|
||||
char **kwlist, va_list *p_va, int flags)
|
||||
const char * const *kwlist, va_list *p_va, int flags)
|
||||
{
|
||||
char msgbuf[512];
|
||||
int levels[32];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue