summaryrefslogtreecommitdiff
path: root/Modules/cStringIO.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-02-09 23:44:22 +0000
committerJeremy Hylton <jeremy@alum.mit.edu>2001-02-09 23:44:22 +0000
commitb6aa64b49ac434f4e3940ab9c7026d1c88a730b3 (patch)
tree157015f4212c0654c50b5d9af75079465fc5d4e5 /Modules/cStringIO.c
parent8d33817b3d542ac9f3f7e3d1509e45dc99ac8d8c (diff)
downloadcpython-b6aa64b49ac434f4e3940ab9c7026d1c88a730b3.tar.gz
In O_writelines: Replace use of string.joinfields with "".join.
Diffstat (limited to 'Modules/cStringIO.c')
-rw-r--r--Modules/cStringIO.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index 1cb40ea8bd..ddf369901a 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -460,20 +460,23 @@ static char O_writelines__doc__[] =
static PyObject *
O_writelines(Oobject *self, PyObject *args) {
PyObject *tmp = 0;
- static PyObject *string_joinfields = 0;
+ static PyObject *joiner = NULL;
UNLESS (PyArg_ParseTuple(args, "O:writelines", &args)) return NULL;
- if (!string_joinfields) {
- UNLESS (tmp = PyImport_ImportModule("string")) return NULL;
- string_joinfields=PyObject_GetAttrString(tmp, "joinfields");
- Py_DECREF(tmp);
- UNLESS (string_joinfields) return NULL;
- }
+ if (!joiner) {
+ PyObject *empty_string = PyString_FromString("");
+ if (empty_string == NULL)
+ return NULL;
+ joiner = PyObject_GetAttrString(empty_string, "join");
+ Py_DECREF(empty_string);
+ if (joiner == NULL)
+ return NULL;
+ }
if (PyObject_Size(args) < 0) return NULL;
- tmp = PyObject_CallFunction(string_joinfields, "Os", args, "");
+ tmp = PyObject_CallFunction(joiner, "O", args);
UNLESS (tmp) return NULL;
args = Py_BuildValue("(O)", tmp);