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
5
Objects/clinic/codeobject.c.h
generated
5
Objects/clinic/codeobject.c.h
generated
|
|
@ -46,7 +46,8 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
|||
PyObject *freevars = NULL;
|
||||
PyObject *cellvars = NULL;
|
||||
|
||||
if ((type == &PyCode_Type) &&
|
||||
if ((type == &PyCode_Type ||
|
||||
type->tp_init == PyCode_Type.tp_init) &&
|
||||
!_PyArg_NoKeywords("code", kwargs)) {
|
||||
goto exit;
|
||||
}
|
||||
|
|
@ -455,4 +456,4 @@ code__varname_from_oparg(PyCodeObject *self, PyObject *const *args, Py_ssize_t n
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=18b9ddc86714e56e input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=9e8c4a19474ec520 input=a9049054013a1b77]*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue