mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
complain when a class variable shadows a name in __slots__ (closes #12766)
This commit is contained in:
parent
51be6e0a0f
commit
c4085c8470
3 changed files with 17 additions and 0 deletions
|
@ -2094,6 +2094,12 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
|||
if (!tmp)
|
||||
goto bad_slots;
|
||||
PyList_SET_ITEM(newslots, j, tmp);
|
||||
if (PyDict_GetItem(dict, tmp)) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%R in __slots__ conflicts with class variable",
|
||||
tmp);
|
||||
goto bad_slots;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
assert(j == nslots - add_dict - add_weak);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue