diff options
author | Michael Seifert <michaelseifert04@yahoo.de> | 2017-03-15 05:26:33 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-15 05:26:33 (GMT) |
commit | 6c3d5274687c97f9c13800ad50e73e15b54f629d (patch) | |
tree | c76bba1b35b7200996e6b33002749c99621ddce4 /Modules | |
parent | 024b4fdc4a981ec9ec17f2e63124ec542eb728ff (diff) | |
download | cpython-6c3d5274687c97f9c13800ad50e73e15b54f629d.zip cpython-6c3d5274687c97f9c13800ad50e73e15b54f629d.tar.gz cpython-6c3d5274687c97f9c13800ad50e73e15b54f629d.tar.bz2 |
bpo-29800: Fix crashes in partial.__repr__ if the keys of partial.keywords are not strings (#649)
Diffstat (limited to 'Modules')
-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 f2af4ab..592edbb 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; } |