Commit 31e7e02d authored by Jim Fulton's avatar Jim Fulton

Added writelines fix from Guido.

parent 9b6740ec
/* /*
* $Id: cStringIO.c,v 1.27 1998/12/15 20:32:13 jim Exp $ * $Id: cStringIO.c,v 1.28 1999/02/08 23:24:40 jim Exp $
* *
* Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA. * Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
* All rights reserved. * All rights reserved.
...@@ -78,7 +78,7 @@ static char cStringIO_module_documentation[] = ...@@ -78,7 +78,7 @@ static char cStringIO_module_documentation[] =
"If someone else wants to provide a more complete implementation,\n" "If someone else wants to provide a more complete implementation,\n"
"go for it. :-) \n" "go for it. :-) \n"
"\n" "\n"
"$Id: cStringIO.c,v 1.27 1998/12/15 20:32:13 jim Exp $\n" "$Id: cStringIO.c,v 1.28 1999/02/08 23:24:40 jim Exp $\n"
; ;
#include "Python.h" #include "Python.h"
...@@ -343,13 +343,14 @@ O_flush(Oobject *self, PyObject *args) { ...@@ -343,13 +343,14 @@ O_flush(Oobject *self, PyObject *args) {
} }
static char O_writelines__doc__[] = "blah"; static char O_writelines__doc__[] =
"writelines(sequence_of_strings): write each string";
static PyObject * static PyObject *
O_writelines(Oobject *self, PyObject *args) { O_writelines(Oobject *self, PyObject *args) {
PyObject *string_module = 0; PyObject *string_module = 0;
static PyObject *string_joinfields = 0; static PyObject *string_joinfields = 0;
UNLESS(PyArg_ParseTuple(args, "O", args)) { UNLESS(PyArg_ParseTuple(args, "O", &args)) {
return NULL; return NULL;
} }
...@@ -370,8 +371,19 @@ O_writelines(Oobject *self, PyObject *args) { ...@@ -370,8 +371,19 @@ O_writelines(Oobject *self, PyObject *args) {
return NULL; return NULL;
} }
return O_write(self, {
PyObject_CallFunction(string_joinfields, "Os", args, "")); PyObject *x = PyObject_CallFunction(string_joinfields,
"Os", args, "");
if (x == NULL)
return NULL;
args = Py_BuildValue("(O)", x);
Py_DECREF(x);
if (args == NULL)
return NULL;
x = O_write(self, args);
Py_DECREF(args);
return x;
}
} }
static struct PyMethodDef O_methods[] = { static struct PyMethodDef O_methods[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment