[Python-checkins] CVS: python/dist/src/Modules cStringIO.c,2.27,2.28
Jeremy Hylton
jhylton@users.sourceforge.net
Fri, 09 Feb 2001 15:44:24 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv21664/Modules
Modified Files:
cStringIO.c
Log Message:
In O_writelines: Replace use of string.joinfields with "".join.
Index: cStringIO.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v
retrieving revision 2.27
retrieving revision 2.28
diff -C2 -r2.27 -r2.28
*** cStringIO.c 2000/10/06 19:24:23 2.27
--- cStringIO.c 2001/02/09 23:44:22 2.28
***************
*** 461,478 ****
O_writelines(Oobject *self, PyObject *args) {
PyObject *tmp = 0;
! static PyObject *string_joinfields = 0;
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 (PyObject_Size(args) < 0) return NULL;
! tmp = PyObject_CallFunction(string_joinfields, "Os", args, "");
UNLESS (tmp) return NULL;
--- 461,481 ----
O_writelines(Oobject *self, PyObject *args) {
PyObject *tmp = 0;
! static PyObject *joiner = NULL;
UNLESS (PyArg_ParseTuple(args, "O:writelines", &args)) 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(joiner, "O", args);
UNLESS (tmp) return NULL;