Mercurial > cpython-lru_cache-weakref
diff Modules/_sqlite/cache.c @ 73403:386a319b1825
Issue #13350: Replace most usages of PyUnicode_Format by PyUnicode_FromFormat.
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> |
|---|---|
| date | Sun, 06 Nov 2011 15:10:48 +0100 |
| parents | e9cd15d539e1 |
| children | a04d957c8d07 |
line wrap: on
line diff
--- a/Modules/_sqlite/cache.c Sun Nov 06 09:26:17 2011 +0200 +++ b/Modules/_sqlite/cache.c Sun Nov 06 15:10:48 2011 +0100 @@ -217,8 +217,6 @@ pysqlite_Node* ptr; PyObject* prevkey; PyObject* nextkey; - PyObject* fmt_args; - PyObject* template; PyObject* display_str; ptr = self->first; @@ -229,36 +227,21 @@ } else { prevkey = Py_None; } - Py_INCREF(prevkey); if (ptr->next) { nextkey = ptr->next->key; } else { nextkey = Py_None; } - Py_INCREF(nextkey); - fmt_args = Py_BuildValue("OOO", prevkey, ptr->key, nextkey); - if (!fmt_args) { - return NULL; - } - template = PyUnicode_FromString("%s <- %s ->%s\n"); - if (!template) { - Py_DECREF(fmt_args); - return NULL; - } - display_str = PyUnicode_Format(template, fmt_args); - Py_DECREF(template); - Py_DECREF(fmt_args); + display_str = PyUnicode_FromFormat("%S <- %S -> %S\n", + prevkey, ptr->key, nextkey); if (!display_str) { return NULL; } PyObject_Print(display_str, stdout, Py_PRINT_RAW); Py_DECREF(display_str); - Py_DECREF(prevkey); - Py_DECREF(nextkey); - ptr = ptr->next; }
