summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2020-04-10 01:05:38 (GMT)
committerGitHub <noreply@github.com>2020-04-10 01:05:38 (GMT)
commit38ada3bac8205a7690d573d715b0e84e60297c4c (patch)
treea29ada4ddeb830fba26732a17d17e1652ec8c409
parent5cd28030092eaa8eb9223afd733974fd2afc8e2c (diff)
downloadcpython-38ada3bac8205a7690d573d715b0e84e60297c4c.zip
cpython-38ada3bac8205a7690d573d715b0e84e60297c4c.tar.gz
cpython-38ada3bac8205a7690d573d715b0e84e60297c4c.tar.bz2
bpo-39943: Keep constness of pointer objects. (19405)
* Keep constness of pointer objects. Also moved an auto variable that got consted into its innermost necessary scope. * move def Co-authored-by: Benjamin Peterson <benjamin@python.org>
-rw-r--r--Objects/typeobject.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ca26d96..bc42e2d 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2857,19 +2857,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;
+ char *res_start;
nmembers = weaklistoffset = dictoffset = 0;
for (slot = spec->slots; slot->slot; slot++) {
if (slot->slot == Py_tp_members) {
nmembers = 0;
- for (memb = slot->pfunc; memb->name != NULL; memb++) {
+ for (const PyMemberDef *memb = slot->pfunc; memb->name != NULL; memb++) {
nmembers++;
if (strcmp(memb->name, "__weaklistoffset__") == 0) {
// The PyMemberDef must be a Py_ssize_t and readonly
@@ -2899,9 +2898,9 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
}
/* Set the type name and qualname */
- s = strrchr(spec->name, '.');
+ const char *s = strrchr(spec->name, '.');
if (s == NULL)
- s = (char*)spec->name;
+ s = spec->name;
else
s++;