mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-29800: Fix crashes in partial.__repr__ if the keys of partial.keywords are not strings (#649)
This commit is contained in:
parent
024b4fdc4a
commit
6c3d527468
4 changed files with 34 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue