Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add const to PyObject pointers (and PyTypeObject is a subtype of PyObject). They are inherently mutable. If the particular function does not mutate them in the particular Python version, it is just an implementation detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I know we've discussed before, but this was an old branch. Sorry. I'll resubmit.

static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *);
static int add_subclass(PyTypeObject*, PyTypeObject*);
static int add_all_subclasses(PyTypeObject *type, PyObject *bases);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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++;

Expand Down