From 323d2ae3462c1d47adc79236ec509e08af61015d Mon Sep 17 00:00:00 2001 From: Andy Lester Date: Thu, 26 Mar 2020 19:48:20 -0500 Subject: [PATCH] Keep constness of pointer objects. Also moved an auto variable that got consted into its innermost necessary scope. --- Objects/typeobject.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index bed50d1e7f2d3c..58f7341df04af9 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -625,7 +625,7 @@ type_get_bases(PyTypeObject *type, void *context) static PyTypeObject *best_base(PyObject *); static int mro_internal(PyTypeObject *, PyObject **); -static int type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *); +static int type_is_subtype_base_chain(const PyTypeObject *, const PyTypeObject *); static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *); static int add_subclass(PyTypeObject*, PyTypeObject*); static int add_all_subclasses(PyTypeObject *type, PyObject *bases); @@ -1362,7 +1362,7 @@ static PyTypeObject *solid_base(PyTypeObject *type); /* type test with subclassing support */ static int -type_is_subtype_base_chain(PyTypeObject *a, PyTypeObject *b) +type_is_subtype_base_chain(const PyTypeObject *a, const PyTypeObject *b) { do { if (a == b) @@ -2850,17 +2850,18 @@ PyObject * PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) { PyHeapTypeObject *res; - PyMemberDef *memb; PyObject *modname; PyTypeObject *type, *base; - PyType_Slot *slot; + const PyType_Slot *slot; Py_ssize_t nmembers, weaklistoffset, dictoffset; - char *s, *res_start; + const char *s; + char *res_start; nmembers = weaklistoffset = dictoffset = 0; for (slot = spec->slots; slot->slot; slot++) { if (slot->slot == Py_tp_members) { + const PyMemberDef *memb; nmembers = 0; for (memb = slot->pfunc; memb->name != NULL; memb++) { nmembers++; @@ -2894,7 +2895,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) /* Set the type name and qualname */ s = strrchr(spec->name, '.'); if (s == NULL) - s = (char*)spec->name; + s = spec->name; else s++;