8000 bpo-39943: Keep constness of pointer objects. (19405) · python/cpython@38ada3b · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 38ada3b

Browse files
petdancebenjaminp
andauthored
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>
1 parent 5cd2803 commit 38ada3b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Objects/typeobject.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,19 +2857,18 @@ PyObject *
28572857
PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
28582858
{
28592859
PyHeapTypeObject *res;
2860-
PyMemberDef *memb;
28612860
PyObject *modname;
28622861
PyTypeObject *type, *base;
28632862

2864-
PyType_Slot *slot;
2863+
const PyType_Slot *slot;
28652864
Py_ssize_t nmembers, weaklistoffset, dictoffset;
2866-
char *s, *res_start;
2865+
char *res_start;
28672866

28682867
nmembers = weaklistoffset = dictoffset = 0;
28692868
for (slot = spec->slots; slot->slot; slot++) {
28702869
if (slot->slot == Py_tp_members) {
28712870
nmembers = 0;
2872-
for (memb = slot->pfunc; memb->name != NULL; memb++) {
2871+
for (const PyMemberDef *memb = slot->pfunc; memb->name != NULL; memb++) {
28732872
nmembers++;
28742873
if (strcmp(memb->name, "__weaklistoffset__") == 0) {
28752874
// The PyMemberDef must be a Py_ssize_t and readonly
@@ -2899,9 +2898,9 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
28992898
}
29002899

29012900
/* Set the type name and qualname */
2902-
s = strrchr(spec->name, '.');
2901+
const char *s = strrchr(spec->name, '.');
29032902
if (s == NULL)
2904-
s = (char*)spec->name;
2903+
s = spec->name;
29052904
else
29062905
s++;
29072906

0 commit comments

Comments
 (0)
0