[Python-checkins] CVS: python/dist/src/Modules cStringIO.c,2.29,2.30
M.-A. Lemburg
lemburg@users.sourceforge.net
Mon, 24 Sep 2001 10:34:55 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv20159/Modules
Modified Files:
cStringIO.c
Log Message:
StringIO patch #462596: let's [c]StringIO accept read buffers on
input to .write() too.
Index: cStringIO.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v
retrieving revision 2.29
retrieving revision 2.30
diff -C2 -d -r2.29 -r2.30
*** cStringIO.c 2001/09/22 04:36:49 2.29
--- cStringIO.c 2001/09/24 17:34:52 2.30
***************
*** 121,125 ****
char *buf;
int pos, string_size;
!
PyObject *pbuf;
} Iobject;
--- 121,126 ----
char *buf;
int pos, string_size;
! /* We store a reference to the object here in order to keep
! the buffer alive during the lifetime of the Iobject. */
PyObject *pbuf;
} Iobject;
***************
*** 425,436 ****
static PyObject *
O_write(Oobject *self, PyObject *args) {
- PyObject *s;
char *c;
int l;
! UNLESS (PyArg_ParseTuple(args, "O:write", &s)) return NULL;
- UNLESS (-1 != (l=PyString_Size(s))) return NULL;
- UNLESS (c=PyString_AsString(s)) return NULL;
if (O_cwrite((PyObject*)self,c,l) < 0) return NULL;
--- 426,434 ----
static PyObject *
O_write(Oobject *self, PyObject *args) {
char *c;
int l;
! UNLESS (PyArg_ParseTuple(args, "s#:write", &c, &l)) return NULL;
if (O_cwrite((PyObject*)self,c,l) < 0) return NULL;
***************
*** 714,724 ****
int size;
! if (!PyString_Check(s)) {
! PyErr_Format(PyExc_TypeError, "expected string, %.200s found",
s->ob_type->tp_name);
return NULL;
}
- buf = PyString_AS_STRING(s);
- size = PyString_GET_SIZE(s);
UNLESS (self = PyObject_New(Iobject, &Itype)) return NULL;
Py_INCREF(s);
--- 712,720 ----
int size;
! if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
! PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found",
s->ob_type->tp_name);
return NULL;
}
UNLESS (self = PyObject_New(Iobject, &Itype)) return NULL;
Py_INCREF(s);