diff options
author | Michael Seifert <michaelseifert04@yahoo.de> | 2017-03-15 06:26:33 +0100 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-15 07:26:33 +0200 |
commit | 6c3d5274687c97f9c13800ad50e73e15b54f629d (patch) | |
tree | c76bba1b35b7200996e6b33002749c99621ddce4 /Modules/_functoolsmodule.c | |
parent | 024b4fdc4a981ec9ec17f2e63124ec542eb728ff (diff) | |
download | cpython-git-6c3d5274687c97f9c13800ad50e73e15b54f629d.tar.gz |
bpo-29800: Fix crashes in partial.__repr__ if the keys of partial.keywords are not strings (#649)
Diffstat (limited to 'Modules/_functoolsmodule.c')
-rw-r--r-- | Modules/_functoolsmodule.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index f2af4ab462..592edbb614 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -297,8 +297,11 @@ partial_repr(partialobject *pto) /* Pack keyword arguments */ assert (PyDict_Check(pto->kw)); for (i = 0; PyDict_Next(pto->kw, &i, &key, &value);) { - Py_SETREF(arglist, PyUnicode_FromFormat("%U, %U=%R", arglist, + /* Prevent key.__str__ from deleting the value. */ + Py_INCREF(value); + Py_SETREF(arglist, PyUnicode_FromFormat("%U, %S=%R", arglist, key, value)); + Py_DECREF(value); if (arglist == NULL) goto done; } |