Skip to content
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

bpo-45383: Inherit MetaClass from bases in FromSpec API #28748

Merged
merged 19 commits into from
Jun 9, 2022
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
Prev Previous commit
Next Next commit
Disallow non-type metaclasses
  • Loading branch information
encukou committed May 27, 2022
commit aad745657bd69039ea906286a5bacf38174f95cc
7 changes: 7 additions & 0 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3455,6 +3455,13 @@ PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module,
Py_DECREF(bases);
goto fail;
}
if (!PyType_Check(metaclass)) {
Py_DECREF(bases);
PyErr_Format(PyExc_TypeError,
"Metaclass '%R' is not a subclass of 'type'.",
metaclass);
goto fail;
}
if (metaclass->tp_new != PyType_Type.tp_new) {
seberg marked this conversation as resolved.
Show resolved Hide resolved
Py_DECREF(bases);
PyErr_SetString(PyExc_TypeError,
Expand Down