diff options
author | Michael Seifert <michaelseifert04@yahoo.de> | 2017-03-15 07:42:02 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-15 07:42:02 (GMT) |
commit | 53b2667dcf2a7d13af466a5fb91844f5125a920d (patch) | |
tree | db0a2a111d9c9d361676abdfca7974291304d732 /Modules | |
parent | faa2cc63e45bc7d7ffab84bebe5a9f4fe065bd96 (diff) | |
download | cpython-53b2667dcf2a7d13af466a5fb91844f5125a920d.zip cpython-53b2667dcf2a7d13af466a5fb91844f5125a920d.tar.gz cpython-53b2667dcf2a7d13af466a5fb91844f5125a920d.tar.bz2 |
bpo-29800: Fix crashes in partial.__repr__ if the keys of partial.keywords are not strings (#649) (#671)
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 7abc9f4..1bcf16a 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -250,8 +250,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; } |