mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Tighten the tests for assignment to __bases__: disallow empty tuple.
This commit is contained in:
parent
3d87e3cdf7
commit
3bbc0eea10
2 changed files with 14 additions and 0 deletions
|
|
@ -211,6 +211,12 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
|
|||
type->tp_name, value->ob_type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
if (PyTuple_GET_SIZE(value) == 0) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can only assign non-empty tuple to %s.__bases__, not ()",
|
||||
type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < PyTuple_GET_SIZE(value); i++) {
|
||||
ob = PyTuple_GET_ITEM(value, i);
|
||||
if (!PyClass_Check(ob) && !PyType_Check(ob)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue