Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-94673: More Per-Interpreter Fields for Builtin Static Types #103912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
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
Next Next commit
Make __mro__ a getter.
  • Loading branch information
ericsnowcurrently committed May 2, 2023
commit d1e4cf57287c0f253dd93687f5cf271883d27c5b
8 changes: 7 additions & 1 deletion 8 Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ static PyMemberDef type_members[] = {
{"__base__", T_OBJECT, offsetof(PyTypeObject, tp_base), READONLY},
{"__dictoffset__", T_PYSSIZET,
offsetof(PyTypeObject, tp_dictoffset), READONLY},
{"__mro__", T_OBJECT, offsetof(PyTypeObject, tp_mro), READONLY},
{0}
};

Expand Down Expand Up @@ -1026,6 +1025,12 @@ type_get_bases(PyTypeObject *type, void *context)
return Py_NewRef(lookup_tp_bases(type));
}

static PyObject *
type_get_mro(PyTypeObject *type, void *context)
{
return Py_NewRef(lookup_tp_mro(type));
}

static PyTypeObject *best_base(PyObject *);
static int mro_internal(PyTypeObject *, PyObject **);
static int type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *);
Expand Down Expand Up @@ -1402,6 +1407,7 @@ static PyGetSetDef type_getsets[] = {
{"__name__", (getter)type_name, (setter)type_set_name, NULL},
{"__qualname__", (getter)type_qualname, (setter)type_set_qualname, NULL},
{"__bases__", (getter)type_get_bases, (setter)type_set_bases, NULL},
{"__mro__", (getter)type_get_mro, NULL, NULL},
{"__module__", (getter)type_module, (setter)type_set_module, NULL},
{"__abstractmethods__", (getter)type_abstractmethods,
(setter)type_set_abstractmethods, NULL},
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.