static PyObject * IO_readlines(IOobject *self, PyObject *args) { int n; char *output; PyObject *result, *line; Py_ssize_t hint = 0, length = 0; if (!PyArg_ParseTuple(args, "|n:readlines", &hint)) return NULL; result = PyList_New(0); if (!result) return NULL; while (1){ if ( (n = IO_creadline((PyObject*)self,&output)) < 0) goto err; if (n == 0) break; line = PyString_FromStringAndSize (output, n); if (!line) goto err; if (PyList_Append (result, line) == -1) { Py_DECREF (line); goto err; } Py_DECREF (line); length += n; if (hint > 0 && length >= hint) break; } return result; err: Py_DECREF(result); return NULL; }
static PyObject * IO_readline(IOobject *self, PyObject *args) { int n, m=-1; char *output; if (args) if (!PyArg_ParseTuple(args, "|i:readline", &m)) return NULL; if( (n=IO_creadline((PyObject*)self,&output)) < 0) return NULL; if (m >= 0 && m < n) { m = n - m; n -= m; self->pos -= m; } return PyString_FromStringAndSize(output, n); }
static PyObject * IO_readline(IOobject *self, PyObject *m_obj) { int n, m=-1; char *output; // Pyston change: if (m_obj) if (!PyArg_ParseSingle(m_obj, 1, "readline", "i", &m)) return NULL; if( (n=IO_creadline((PyObject*)self,&output)) < 0) return NULL; if (m >= 0 && m < n) { m = n - m; n -= m; self->pos -= m; } assert(IOOOBJECT(self)->pos >= 0); return PyString_FromStringAndSize(output, n); }