bpo-29532: Altering a kwarg dictionary passed to functools.partial() (#190)

no longer affects a partial object after creation.
This commit is contained in:
Serhiy Storchaka 2017-02-20 14:04:30 +02:00 committed by GitHub
parent d0e8212ed7
commit 9639e4ab6d
3 changed files with 16 additions and 1 deletions

View file

@ -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);