From 92bf8691fb78f3484bf2daba836c416efedb1d8d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 12 Sep 2021 13:27:50 +0300 Subject: 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__(). --- Modules/arraymodule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Modules/arraymodule.c') diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 1d9d4cd591..9a3203c7ca 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2617,7 +2617,9 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyObject *initial = NULL, *it = NULL; const struct arraydescr *descr; - if (type == state->ArrayType && !_PyArg_NoKeywords("array.array", kwds)) + if ((type == state->ArrayType || + type->tp_init == state->ArrayType->tp_init) && + !_PyArg_NoKeywords("array.array", kwds)) return NULL; if (!PyArg_ParseTuple(args, "C|O:array", &c, &initial)) -- cgit v1.2.1