mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-29532: Altering a kwarg dictionary passed to functools.partial() (#190)
no longer affects a partial object after creation.
This commit is contained in:
parent
d0e8212ed7
commit
9639e4ab6d
3 changed files with 16 additions and 1 deletions
|
@ -88,10 +88,13 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
if (kw == NULL) {
|
||||
pto->kw = PyDict_New();
|
||||
}
|
||||
else {
|
||||
else if (Py_REFCNT(kw) == 1) {
|
||||
Py_INCREF(kw);
|
||||
pto->kw = kw;
|
||||
}
|
||||
else {
|
||||
pto->kw = PyDict_Copy(kw);
|
||||
}
|
||||
}
|
||||
else {
|
||||
pto->kw = PyDict_Copy(pkw);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue