mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
Issue #25923: Added more const qualifiers to signatures of static and private functions.
This commit is contained in:
parent
2d06e84455
commit
ef1585eb9a
60 changed files with 210 additions and 191 deletions
|
|
@ -2576,8 +2576,8 @@ bytearray_remove_impl(PyByteArrayObject *self, int value)
|
|||
/* XXX These two helpers could be optimized if argsize == 1 */
|
||||
|
||||
static Py_ssize_t
|
||||
lstrip_helper(char *myptr, Py_ssize_t mysize,
|
||||
void *argptr, Py_ssize_t argsize)
|
||||
lstrip_helper(const char *myptr, Py_ssize_t mysize,
|
||||
const void *argptr, Py_ssize_t argsize)
|
||||
{
|
||||
Py_ssize_t i = 0;
|
||||
while (i < mysize && memchr(argptr, (unsigned char) myptr[i], argsize))
|
||||
|
|
@ -2586,8 +2586,8 @@ lstrip_helper(char *myptr, Py_ssize_t mysize,
|
|||
}
|
||||
|
||||
static Py_ssize_t
|
||||
rstrip_helper(char *myptr, Py_ssize_t mysize,
|
||||
void *argptr, Py_ssize_t argsize)
|
||||
rstrip_helper(const char *myptr, Py_ssize_t mysize,
|
||||
const void *argptr, Py_ssize_t argsize)
|
||||
{
|
||||
Py_ssize_t i = mysize - 1;
|
||||
while (i >= 0 && memchr(argptr, (unsigned char) myptr[i], argsize))
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ Return a titlecased version of B, i.e. ASCII words start with uppercase\n\
|
|||
characters, all remaining cased characters have lowercase.");
|
||||
|
||||
void
|
||||
_Py_bytes_title(char *result, char *s, Py_ssize_t len)
|
||||
_Py_bytes_title(char *result, const char *s, Py_ssize_t len)
|
||||
{
|
||||
Py_ssize_t i;
|
||||
int previous_is_cased = 0;
|
||||
|
|
@ -306,7 +306,7 @@ Return a copy of B with only its first character capitalized (ASCII)\n\
|
|||
and the rest lower-cased.");
|
||||
|
||||
void
|
||||
_Py_bytes_capitalize(char *result, char *s, Py_ssize_t len)
|
||||
_Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len)
|
||||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
|
|
@ -336,7 +336,7 @@ Return a copy of B with uppercase ASCII characters converted\n\
|
|||
to lowercase ASCII and vice versa.");
|
||||
|
||||
void
|
||||
_Py_bytes_swapcase(char *result, char *s, Py_ssize_t len)
|
||||
_Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len)
|
||||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ PyBytes_FromFormatV(const char *format, va_list vargs)
|
|||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
p = va_arg(vargs, char*);
|
||||
p = va_arg(vargs, const char*);
|
||||
i = strlen(p);
|
||||
if (prec > 0 && i > prec)
|
||||
i = prec;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ descr_name(PyDescrObject *descr)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
descr_repr(PyDescrObject *descr, char *format)
|
||||
descr_repr(PyDescrObject *descr, const char *format)
|
||||
{
|
||||
PyObject *name = NULL;
|
||||
if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
|
||||
|
|
|
|||
|
|
@ -1925,7 +1925,7 @@ dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value)
|
|||
}
|
||||
|
||||
static int
|
||||
dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methname)
|
||||
dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, const char *methname)
|
||||
{
|
||||
PyObject *arg = NULL;
|
||||
int result = 0;
|
||||
|
|
|
|||
|
|
@ -1133,7 +1133,7 @@ get_native_fmtchar(char *result, const char *fmt)
|
|||
return -1;
|
||||
}
|
||||
|
||||
Py_LOCAL_INLINE(char *)
|
||||
Py_LOCAL_INLINE(const char *)
|
||||
get_native_fmtstr(const char *fmt)
|
||||
{
|
||||
int at = 0;
|
||||
|
|
@ -1221,7 +1221,7 @@ cast_to_1D(PyMemoryViewObject *mv, PyObject *format)
|
|||
goto out;
|
||||
}
|
||||
|
||||
view->format = get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
|
||||
view->format = (char *)get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
|
||||
if (view->format == NULL) {
|
||||
/* NOT_REACHED: get_native_fmtchar() already validates the format. */
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ type_get_bases(PyTypeObject *type, void *context)
|
|||
static PyTypeObject *best_base(PyObject *);
|
||||
static int mro_internal(PyTypeObject *, PyObject **);
|
||||
Py_LOCAL_INLINE(int) type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *);
|
||||
static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, char *);
|
||||
static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *);
|
||||
static int add_subclass(PyTypeObject*, PyTypeObject*);
|
||||
static int add_all_subclasses(PyTypeObject *type, PyObject *bases);
|
||||
static void remove_subclass(PyTypeObject *, PyTypeObject *);
|
||||
|
|
@ -1435,7 +1435,7 @@ _PyObject_LookupSpecial(PyObject *self, _Py_Identifier *attrid)
|
|||
as lookup_method to cache the interned name string object. */
|
||||
|
||||
static PyObject *
|
||||
call_method(PyObject *o, _Py_Identifier *nameid, char *format, ...)
|
||||
call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
PyObject *args, *func = 0, *retval;
|
||||
|
|
@ -1471,7 +1471,7 @@ call_method(PyObject *o, _Py_Identifier *nameid, char *format, ...)
|
|||
/* Clone of call_method() that returns NotImplemented when the lookup fails. */
|
||||
|
||||
static PyObject *
|
||||
call_maybe(PyObject *o, _Py_Identifier *nameid, char *format, ...)
|
||||
call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
PyObject *args, *func = 0, *retval;
|
||||
|
|
@ -3609,7 +3609,7 @@ same_slots_added(PyTypeObject *a, PyTypeObject *b)
|
|||
}
|
||||
|
||||
static int
|
||||
compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, char* attr)
|
||||
compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, const char* attr)
|
||||
{
|
||||
PyTypeObject *newbase, *oldbase;
|
||||
|
||||
|
|
@ -5348,7 +5348,7 @@ wrap_delitem(PyObject *self, PyObject *args, void *wrapped)
|
|||
/* Helper to check for object.__setattr__ or __delattr__ applied to a type.
|
||||
This is called the Carlo Verre hack after its discoverer. */
|
||||
static int
|
||||
hackcheck(PyObject *self, setattrofunc func, char *what)
|
||||
hackcheck(PyObject *self, setattrofunc func, const char *what)
|
||||
{
|
||||
PyTypeObject *type = Py_TYPE(self);
|
||||
while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE)
|
||||
|
|
|
|||
|
|
@ -6986,7 +6986,7 @@ PyUnicode_AsASCIIString(PyObject *unicode)
|
|||
# define WC_ERR_INVALID_CHARS 0x0080
|
||||
#endif
|
||||
|
||||
static char*
|
||||
static const char*
|
||||
code_page_name(UINT code_page, PyObject **obj)
|
||||
{
|
||||
*obj = NULL;
|
||||
|
|
@ -7094,7 +7094,7 @@ decode_code_page_errors(UINT code_page,
|
|||
PyObject *errorHandler = NULL;
|
||||
PyObject *exc = NULL;
|
||||
PyObject *encoding_obj = NULL;
|
||||
char *encoding;
|
||||
const char *encoding;
|
||||
DWORD err;
|
||||
int ret = -1;
|
||||
|
||||
|
|
@ -7438,7 +7438,7 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes,
|
|||
PyObject *errorHandler = NULL;
|
||||
PyObject *exc = NULL;
|
||||
PyObject *encoding_obj = NULL;
|
||||
char *encoding;
|
||||
const char *encoding;
|
||||
Py_ssize_t newpos, newoutsize;
|
||||
PyObject *rep;
|
||||
int ret = -1;
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ insert_head(PyWeakReference *newref, PyWeakReference **list)
|
|||
}
|
||||
|
||||
static int
|
||||
parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs,
|
||||
parse_weakref_init_args(const char *funcname, PyObject *args, PyObject *kwargs,
|
||||
PyObject **obp, PyObject **callbackp)
|
||||
{
|
||||
/* XXX Should check that kwargs == NULL or is empty. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue