mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03: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
|
|
@ -1614,7 +1614,8 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
Py_ssize_t numargs;
|
||||
isliceobject *lz;
|
||||
|
||||
if (type == &islice_type && !_PyArg_NoKeywords("islice", kwds))
|
||||
if ((type == &islice_type || type->tp_init == islice_type.tp_init) &&
|
||||
!_PyArg_NoKeywords("islice", kwds))
|
||||
return NULL;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "islice", 2, 4, &seq, &a1, &a2, &a3))
|
||||
|
|
@ -2021,7 +2022,8 @@ chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
{
|
||||
PyObject *source;
|
||||
|
||||
if (type == &chain_type && !_PyArg_NoKeywords("chain", kwds))
|
||||
if ((type == &chain_type || type->tp_init == chain_type.tp_init) &&
|
||||
!_PyArg_NoKeywords("chain", kwds))
|
||||
return NULL;
|
||||
|
||||
source = PyObject_GetIter(args);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue