mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-43413: Fix handling keyword arguments in subclasses of some buitin classes (GH-26456)
* Constructors of subclasses of some buitin classes (e.g. tuple, list, frozenset) no longer accept arbitrary keyword arguments. * Subclass of set can now define a __new__() method with additional keyword parameters without overriding also __init__().
This commit is contained in:
parent
5277ffe12d
commit
92bf8691fb
26 changed files with 285 additions and 67 deletions
|
@ -523,8 +523,9 @@ random_init(RandomObject *self, PyObject *args, PyObject *kwds)
|
|||
PyObject *arg = NULL;
|
||||
_randomstate *state = _randomstate_type(Py_TYPE(self));
|
||||
|
||||
if (Py_IS_TYPE(self, (PyTypeObject *)state->Random_Type) &&
|
||||
!_PyArg_NoKeywords("Random()", kwds)) {
|
||||
if ((Py_IS_TYPE(self, (PyTypeObject *)state->Random_Type) ||
|
||||
Py_TYPE(self)->tp_init == ((PyTypeObject*)state->Random_Type)->tp_init) &&
|
||||
!_PyArg_NoKeywords("Random", kwds)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue