mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
only accept AttributeError as indicating no __prepare__ attribute on a metaclass, allowing lookup errors to propogate
This commit is contained in:
parent
8de42e2d50
commit
23e018ab98
3 changed files with 26 additions and 2 deletions
|
@ -108,8 +108,16 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
prep = PyObject_GetAttrString(meta, "__prepare__");
|
||||
if (prep == NULL) {
|
||||
PyErr_Clear();
|
||||
ns = PyDict_New();
|
||||
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||
PyErr_Clear();
|
||||
ns = PyDict_New();
|
||||
}
|
||||
else {
|
||||
Py_DECREF(meta);
|
||||
Py_XDECREF(mkw);
|
||||
Py_DECREF(bases);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyObject *pargs = PyTuple_Pack(2, name, bases);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue