summaryrefslogtreecommitdiffstats
path: root/Modules/arraymodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-09-12 10:27:50 (GMT)
committerGitHub <noreply@github.com>2021-09-12 10:27:50 (GMT)
commit92bf8691fb78f3484bf2daba836c416efedb1d8d (patch)
treef5e605dbb607ec58daa687300a5f59f99dd1aee4 /Modules/arraymodule.c
parent5277ffe12d492939544ff9c54a3aaf448b913fb3 (diff)
downloadcpython-92bf8691fb78f3484bf2daba836c416efedb1d8d.zip
cpython-92bf8691fb78f3484bf2daba836c416efedb1d8d.tar.gz
cpython-92bf8691fb78f3484bf2daba836c416efedb1d8d.tar.bz2
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__().
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 1d9d4cd..9a3203c 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))