Document why functools.partial() must copy kwargs (#253)
Add a comment to prevent further attempts to avoid a copy for optimization.
This commit is contained in:
parent
324c5d8ca6
commit
561ca80cff
|
@ -163,6 +163,9 @@ partial_call(partialobject *pto, PyObject *args, PyObject *kw)
|
||||||
Py_XINCREF(kwappl);
|
Py_XINCREF(kwappl);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
/* bpo-27840, bpo-29318: dictionary of keyword parameters must be
|
||||||
|
copied, because a function using "**kwargs" can modify the
|
||||||
|
dictionary. */
|
||||||
kwappl = PyDict_Copy(pto->kw);
|
kwappl = PyDict_Copy(pto->kw);
|
||||||
if (kwappl == NULL) {
|
if (kwappl == NULL) {
|
||||||
Py_XDECREF(argappl);
|
Py_XDECREF(argappl);
|
||||||
|
|
|
@ -317,8 +317,8 @@ _PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs,
|
||||||
if (nk != 0) {
|
if (nk != 0) {
|
||||||
Py_ssize_t pos, i;
|
Py_ssize_t pos, i;
|
||||||
|
|
||||||
/* Issue #29318: Caller and callee functions must not share the
|
/* bpo-29318, bpo-27840: Caller and callee functions must not share
|
||||||
dictionary: kwargs must be copied. */
|
the dictionary: kwargs must be copied. */
|
||||||
kwtuple = PyTuple_New(2 * nk);
|
kwtuple = PyTuple_New(2 * nk);
|
||||||
if (kwtuple == NULL) {
|
if (kwtuple == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue