summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2011-11-06 14:10:48 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2011-11-06 14:10:48 (GMT)
commit864741b2c7aaabda736f917694a1d3b26700e8e3 (patch)
tree8a79396976bd3f512eec73f88abfb60ca787377e /Modules
parent08ad2fbc7f7abb687327b22eb7f65ac388742ab9 (diff)
downloadcpython-864741b2c7aaabda736f917694a1d3b26700e8e3.zip
cpython-864741b2c7aaabda736f917694a1d3b26700e8e3.tar.gz
cpython-864741b2c7aaabda736f917694a1d3b26700e8e3.tar.bz2
Issue #13350: Replace most usages of PyUnicode_Format by PyUnicode_FromFormat.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c24
-rw-r--r--Modules/_sqlite/cache.c21
2 files changed, 5 insertions, 40 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index e08dea1a..338c4f7 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -4599,38 +4599,20 @@ static PyNumberMethods Simple_as_number = {
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 --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c
index 735a242..3693363 100644
--- a/Modules/_sqlite/cache.c
+++ b/Modules/_sqlite/cache.c
@@ -217,8 +217,6 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
pysqlite_Node* ptr;
PyObject* prevkey;
PyObject* nextkey;
- PyObject* fmt_args;
- PyObject* template;
PyObject* display_str;
ptr = self->first;
@@ -229,36 +227,21 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
} 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;
}