mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
|
@ -507,7 +507,8 @@ filter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
PyObject *it;
|
||||
filterobject *lz;
|
||||
|
||||
if (type == &PyFilter_Type && !_PyArg_NoKeywords("filter", kwds))
|
||||
if ((type == &PyFilter_Type || type->tp_init == PyFilter_Type.tp_init) &&
|
||||
!_PyArg_NoKeywords("filter", kwds))
|
||||
return NULL;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "filter", 2, 2, &func, &seq))
|
||||
|
@ -1218,7 +1219,8 @@ map_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
mapobject *lz;
|
||||
Py_ssize_t numargs, i;
|
||||
|
||||
if (type == &PyMap_Type && !_PyArg_NoKeywords("map", kwds))
|
||||
if ((type == &PyMap_Type || type->tp_init == PyMap_Type.tp_init) &&
|
||||
!_PyArg_NoKeywords("map", kwds))
|
||||
return NULL;
|
||||
|
||||
numargs = PyTuple_Size(args);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue