]> granicus.if.org Git - python/commitdiff
Document why functools.partial() must copy kwargs (#253)
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 23 Feb 2017 17:26:43 +0000 (18:26 +0100)
committerGitHub <noreply@github.com>
Thu, 23 Feb 2017 17:26:43 +0000 (18:26 +0100)
Add a comment to prevent further attempts to avoid a copy for
optimization.

Modules/_functoolsmodule.c
Objects/call.c

index c8565054c903de93d64ae7fc7e8ef652e47693c3..dcaa99f91fb394f0ee225588e1dea8e1a90b7a2e 100644 (file)
@@ -163,6 +163,9 @@ partial_call(partialobject *pto, PyObject *args, PyObject *kw)
         Py_XINCREF(kwappl);
     }
     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);
         if (kwappl == NULL) {
             Py_XDECREF(argappl);
index bc320909385169c5c3b97a9c66852d40820599a5..310b4a205f384719dc5236b477538a50dc297357 100644 (file)
@@ -317,8 +317,8 @@ _PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs,
     if (nk != 0) {
         Py_ssize_t pos, i;
 
-        /* Issue #29318: Caller and callee functions must not share the
-           dictionary: kwargs must be copied. */
+        /* bpo-29318, bpo-27840: Caller and callee functions must not share
+           the dictionary: kwargs must be copied. */
         kwtuple = PyTuple_New(2 * nk);
         if (kwtuple == NULL) {
             return NULL;