diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-09-12 10:27:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-12 10:27:50 (GMT) |
commit | 92bf8691fb78f3484bf2daba836c416efedb1d8d (patch) | |
tree | f5e605dbb607ec58daa687300a5f59f99dd1aee4 /Modules/clinic | |
parent | 5277ffe12d492939544ff9c54a3aaf448b913fb3 (diff) | |
download | cpython-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/clinic')
-rw-r--r-- | Modules/clinic/_collectionsmodule.c.h | 5 | ||||
-rw-r--r-- | Modules/clinic/_queuemodule.c.h | 8 | ||||
-rw-r--r-- | Modules/clinic/_ssl.c.h | 11 | ||||
-rw-r--r-- | Modules/clinic/itertoolsmodule.c.h | 29 | ||||
-rw-r--r-- | Modules/clinic/selectmodule.c.h | 8 |
5 files changed, 39 insertions, 22 deletions
diff --git a/Modules/clinic/_collectionsmodule.c.h b/Modules/clinic/_collectionsmodule.c.h index 7e18aeb..2875b3c 100644 --- a/Modules/clinic/_collectionsmodule.c.h +++ b/Modules/clinic/_collectionsmodule.c.h @@ -43,7 +43,8 @@ tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) Py_ssize_t index; PyObject *doc; - if ((type == &tuplegetter_type) && + if ((type == &tuplegetter_type || + type->tp_init == tuplegetter_type.tp_init) && !_PyArg_NoKeywords("_tuplegetter", kwargs)) { goto exit; } @@ -68,4 +69,4 @@ tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=947186d369f50f1e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3dfa12a35e655844 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_queuemodule.c.h b/Modules/clinic/_queuemodule.c.h index 8741f7d..d952256 100644 --- a/Modules/clinic/_queuemodule.c.h +++ b/Modules/clinic/_queuemodule.c.h @@ -16,11 +16,13 @@ simplequeue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - if ((type == simplequeue_get_state_by_type(type)->SimpleQueueType) && + if ((type == simplequeue_get_state_by_type(type)->SimpleQueueType || + type->tp_init == simplequeue_get_state_by_type(type)->SimpleQueueType->tp_init) && !_PyArg_NoPositional("SimpleQueue", args)) { goto exit; } - if ((type == simplequeue_get_state_by_type(type)->SimpleQueueType) && + if ((type == simplequeue_get_state_by_type(type)->SimpleQueueType || + type->tp_init == simplequeue_get_state_by_type(type)->SimpleQueueType->tp_init) && !_PyArg_NoKeywords("SimpleQueue", kwargs)) { goto exit; } @@ -246,4 +248,4 @@ _queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=ce56b46fac150909 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=96cc57168d72aab1 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_ssl.c.h b/Modules/clinic/_ssl.c.h index b59b129..67eaf3f 100644 --- a/Modules/clinic/_ssl.c.h +++ b/Modules/clinic/_ssl.c.h @@ -408,7 +408,8 @@ _ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *return_value = NULL; int proto_version; - if ((type == get_state_type(type)->PySSLContext_Type) && + if ((type == get_state_type(type)->PySSLContext_Type || + type->tp_init == get_state_type(type)->PySSLContext_Type->tp_init) && !_PyArg_NoKeywords("_SSLContext", kwargs)) { goto exit; } @@ -884,11 +885,13 @@ _ssl_MemoryBIO(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - if ((type == get_state_type(type)->PySSLMemoryBIO_Type) && + if ((type == get_state_type(type)->PySSLMemoryBIO_Type || + type->tp_init == get_state_type(type)->PySSLMemoryBIO_Type->tp_init) && !_PyArg_NoPositional("MemoryBIO", args)) { goto exit; } - if ((type == get_state_type(type)->PySSLMemoryBIO_Type) && + if ((type == get_state_type(type)->PySSLMemoryBIO_Type || + type->tp_init == get_state_type(type)->PySSLMemoryBIO_Type->tp_init) && !_PyArg_NoKeywords("MemoryBIO", kwargs)) { goto exit; } @@ -1358,4 +1361,4 @@ exit: #ifndef _SSL_ENUM_CRLS_METHODDEF #define _SSL_ENUM_CRLS_METHODDEF #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */ -/*[clinic end generated code: output=5a7d7bf5cf8ee092 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cd2a53c26eda295e input=a9049054013a1b77]*/ diff --git a/Modules/clinic/itertoolsmodule.c.h b/Modules/clinic/itertoolsmodule.c.h index 82729ee..7f5abe6 100644 --- a/Modules/clinic/itertoolsmodule.c.h +++ b/Modules/clinic/itertoolsmodule.c.h @@ -19,7 +19,8 @@ pairwise_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *return_value = NULL; PyObject *iterable; - if ((type == &pairwise_type) && + if ((type == &pairwise_type || + type->tp_init == pairwise_type.tp_init) && !_PyArg_NoKeywords("pairwise", kwargs)) { goto exit; } @@ -89,7 +90,8 @@ itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *parent; PyObject *tgtkey; - if ((type == &_grouper_type) && + if ((type == &_grouper_type || + type->tp_init == _grouper_type.tp_init) && !_PyArg_NoKeywords("_grouper", kwargs)) { goto exit; } @@ -126,7 +128,8 @@ itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *values; PyObject *next; - if ((type == &teedataobject_type) && + if ((type == &teedataobject_type || + type->tp_init == teedataobject_type.tp_init) && !_PyArg_NoKeywords("teedataobject", kwargs)) { goto exit; } @@ -161,7 +164,8 @@ itertools__tee(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *return_value = NULL; PyObject *iterable; - if ((type == &tee_type) && + if ((type == &tee_type || + type->tp_init == tee_type.tp_init) && !_PyArg_NoKeywords("_tee", kwargs)) { goto exit; } @@ -235,7 +239,8 @@ itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *return_value = NULL; PyObject *iterable; - if ((type == &cycle_type) && + if ((type == &cycle_type || + type->tp_init == cycle_type.tp_init) && !_PyArg_NoKeywords("cycle", kwargs)) { goto exit; } @@ -267,7 +272,8 @@ itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *func; PyObject *seq; - if ((type == &dropwhile_type) && + if ((type == &dropwhile_type || + type->tp_init == dropwhile_type.tp_init) && !_PyArg_NoKeywords("dropwhile", kwargs)) { goto exit; } @@ -298,7 +304,8 @@ itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *func; PyObject *seq; - if ((type == &takewhile_type) && + if ((type == &takewhile_type || + type->tp_init == takewhile_type.tp_init) && !_PyArg_NoKeywords("takewhile", kwargs)) { goto exit; } @@ -329,7 +336,8 @@ itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *func; PyObject *seq; - if ((type == &starmap_type) && + if ((type == &starmap_type || + type->tp_init == starmap_type.tp_init) && !_PyArg_NoKeywords("starmap", kwargs)) { goto exit; } @@ -593,7 +601,8 @@ itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *func; PyObject *seq; - if ((type == &filterfalse_type) && + if ((type == &filterfalse_type || + type->tp_init == filterfalse_type.tp_init) && !_PyArg_NoKeywords("filterfalse", kwargs)) { goto exit; } @@ -658,4 +667,4 @@ skip_optional_pos: exit: return return_value; } -/*[clinic end generated code: output=889c4afc3b13574f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5364de2e143609b9 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h index d7095df..a1695f2 100644 --- a/Modules/clinic/selectmodule.c.h +++ b/Modules/clinic/selectmodule.c.h @@ -933,11 +933,13 @@ select_kqueue(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - if ((type == _selectstate_by_type(type)->kqueue_queue_Type) && + if ((type == _selectstate_by_type(type)->kqueue_queue_Type || + type->tp_init == _selectstate_by_type(type)->kqueue_queue_Type->tp_init) && !_PyArg_NoPositional("kqueue", args)) { goto exit; } - if ((type == _selectstate_by_type(type)->kqueue_queue_Type) && + if ((type == _selectstate_by_type(type)->kqueue_queue_Type || + type->tp_init == _selectstate_by_type(type)->kqueue_queue_Type->tp_init) && !_PyArg_NoKeywords("kqueue", kwargs)) { goto exit; } @@ -1179,4 +1181,4 @@ exit: #ifndef SELECT_KQUEUE_CONTROL_METHODDEF #define SELECT_KQUEUE_CONTROL_METHODDEF #endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ -/*[clinic end generated code: output=cd2062a787e13b35 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ed1e5a658863244c input=a9049054013a1b77]*/ |