mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-125028: Prohibit placeholders in partial keywords (GH-126062)
This commit is contained in:
parent
4fcd377563
commit
afed5f8835
5 changed files with 37 additions and 2 deletions
|
@ -196,6 +196,19 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* keyword Placeholder prohibition */
|
||||
if (kw != NULL) {
|
||||
PyObject *key, *val;
|
||||
Py_ssize_t pos = 0;
|
||||
while (PyDict_Next(kw, &pos, &key, &val)) {
|
||||
if (val == phold) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Placeholder cannot be passed as a keyword argument");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check wrapped function / object */
|
||||
pto_args = pto_kw = NULL;
|
||||
int res = PyObject_TypeCheck(func, state->partial_type);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue