diff -r bddb455439d0 Doc/includes/noddy2.c --- a/Doc/includes/noddy2.c Fri Nov 04 22:29:24 2011 +0100 +++ b/Doc/includes/noddy2.c Sat Nov 05 22:21:19 2011 +0100 @@ -84,15 +84,6 @@ static PyObject * Noddy_name(Noddy* self) { - static PyObject *format = NULL; - PyObject *args, *result; - - if (format == NULL) { - format = PyUnicode_FromString("%s %s"); - if (format == NULL) - return NULL; - } - if (self->first == NULL) { PyErr_SetString(PyExc_AttributeError, "first"); return NULL; @@ -103,14 +94,7 @@ return NULL; } - args = Py_BuildValue("OO", self->first, self->last); - if (args == NULL) - return NULL; - - result = PyUnicode_Format(format, args); - Py_DECREF(args); - - return result; + return PyUnicode_FromFormat("%S %S", self->first, self->last); } static PyMethodDef Noddy_methods[] = { diff -r bddb455439d0 Doc/includes/noddy3.c --- a/Doc/includes/noddy3.c Fri Nov 04 22:29:24 2011 +0100 +++ b/Doc/includes/noddy3.c Sat Nov 05 22:21:19 2011 +0100 @@ -147,23 +147,7 @@ static PyObject * Noddy_name(Noddy* self) { - static PyObject *format = NULL; - PyObject *args, *result; - - if (format == NULL) { - format = PyUnicode_FromString("%s %s"); - if (format == NULL) - return NULL; - } - - args = Py_BuildValue("OO", self->first, self->last); - if (args == NULL) - return NULL; - - result = PyUnicode_Format(format, args); - Py_DECREF(args); - - return result; + return PyUnicode_FromFormat("%S %S", self->first, self->last); } static PyMethodDef Noddy_methods[] = { diff -r bddb455439d0 Doc/includes/noddy4.c --- a/Doc/includes/noddy4.c Fri Nov 04 22:29:24 2011 +0100 +++ b/Doc/includes/noddy4.c Sat Nov 05 22:21:19 2011 +0100 @@ -118,15 +118,6 @@ static PyObject * Noddy_name(Noddy* self) { - static PyObject *format = NULL; - PyObject *args, *result; - - if (format == NULL) { - format = PyUnicode_FromString("%s %s"); - if (format == NULL) - return NULL; - } - if (self->first == NULL) { PyErr_SetString(PyExc_AttributeError, "first"); return NULL; @@ -137,14 +128,7 @@ return NULL; } - args = Py_BuildValue("OO", self->first, self->last); - if (args == NULL) - return NULL; - - result = PyUnicode_Format(format, args); - Py_DECREF(args); - - return result; + return PyUnicode_FromFormat("%S %S", self->first, self->last); } static PyMethodDef Noddy_methods[] = { diff -r bddb455439d0 Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c Fri Nov 04 22:29:24 2011 +0100 +++ b/Modules/_ctypes/_ctypes.c Sat Nov 05 22:21:19 2011 +0100 @@ -4599,38 +4599,20 @@ static PyObject * Simple_repr(CDataObject *self) { - PyObject *val, *name, *args, *result; - static PyObject *format; + PyObject *val, *result; if (Py_TYPE(self)->tp_base != &Simple_Type) { return PyUnicode_FromFormat("<%s object at %p>", Py_TYPE(self)->tp_name, self); } - if (format == NULL) { - format = PyUnicode_InternFromString("%s(%r)"); - if (format == NULL) - return NULL; - } - val = Simple_get_value(self); if (val == NULL) return NULL; - name = PyUnicode_FromString(Py_TYPE(self)->tp_name); - if (name == NULL) { - Py_DECREF(val); - return NULL; - } - - args = PyTuple_Pack(2, name, val); - Py_DECREF(name); + result = PyUnicode_FromFormat("%s(%R)", + Py_TYPE(self)->tp_name, val); Py_DECREF(val); - if (args == NULL) - return NULL; - - result = PyUnicode_Format(format, args); - Py_DECREF(args); return result; } diff -r bddb455439d0 Modules/_sqlite/cache.c --- a/Modules/_sqlite/cache.c Fri Nov 04 22:29:24 2011 +0100 +++ b/Modules/_sqlite/cache.c Sat Nov 05 22:21:19 2011 +0100 @@ -238,27 +238,16 @@ } 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); + Py_DECREF(prevkey); + Py_DECREF(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; } diff -r bddb455439d0 Objects/listobject.c --- a/Objects/listobject.c Fri Nov 04 22:29:24 2011 +0100 +++ b/Objects/listobject.c Sat Nov 05 22:21:19 2011 +0100 @@ -2121,8 +2121,7 @@ listindex(PyListObject *self, PyObject *args) { Py_ssize_t i, start=0, stop=Py_SIZE(self); - PyObject *v, *format_tuple, *err_string; - static PyObject *err_format = NULL; + PyObject *v; if (!PyArg_ParseTuple(args, "O|O&O&:index", &v, _PyEval_SliceIndex, &start, @@ -2145,20 +2144,7 @@ else if (cmp < 0) return NULL; } - if (err_format == NULL) { - err_format = PyUnicode_FromString("%r is not in list"); - if (err_format == NULL) - return NULL; - } - format_tuple = PyTuple_Pack(1, v); - if (format_tuple == NULL) - return NULL; - err_string = PyUnicode_Format(err_format, format_tuple); - Py_DECREF(format_tuple); - if (err_string == NULL) - return NULL; - PyErr_SetObject(PyExc_ValueError, err_string); - Py_DECREF(err_string); + PyErr_Format(PyExc_ValueError, "%R is not in list", v); return NULL; }