FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-39943: Keep constness of pointer objects. by petdance · Pull Request #19186 · python/cpython · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 7 additions & 6 deletions Objects/typeobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Back | FazBrowse Home | New Git URL