mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30: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
|
|
@ -12,7 +12,8 @@ pysqlite_cursor_init(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
int return_value = -1;
|
||||
pysqlite_Connection *connection;
|
||||
|
||||
if (Py_IS_TYPE(self, clinic_state()->CursorType) &&
|
||||
if ((Py_IS_TYPE(self, clinic_state()->CursorType) ||
|
||||
Py_TYPE(self)->tp_new == clinic_state()->CursorType->tp_new) &&
|
||||
!_PyArg_NoKeywords("Cursor", kwargs)) {
|
||||
goto exit;
|
||||
}
|
||||
|
|
@ -299,4 +300,4 @@ pysqlite_cursor_close(pysqlite_Cursor *self, PyTypeObject *cls, PyObject *const
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=ace31a7481aa3f41 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=3b5328c1619b7626 input=a9049054013a1b77]*/
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ pysqlite_row_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
|||
pysqlite_Cursor *cursor;
|
||||
PyObject *data;
|
||||
|
||||
if ((type == clinic_state()->RowType) &&
|
||||
if ((type == clinic_state()->RowType ||
|
||||
type->tp_init == clinic_state()->RowType->tp_init) &&
|
||||
!_PyArg_NoKeywords("Row", kwargs)) {
|
||||
goto exit;
|
||||
}
|
||||
|
|
@ -53,4 +54,4 @@ pysqlite_row_keys(pysqlite_Row *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return pysqlite_row_keys_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=0382771b4fc85f36 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=9d54919dbb4ba5f1 input=a9049054013a1b77]*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue