Commit d2e9aed7 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Make cStringIO.readline use METH_O

parent a419290b
...@@ -222,12 +222,13 @@ IO_creadline(PyObject *self, char **output) { ...@@ -222,12 +222,13 @@ IO_creadline(PyObject *self, char **output) {
} }
static PyObject * static PyObject *
IO_readline(IOobject *self, PyObject *args) { IO_readline(IOobject *self, PyObject *m_obj) {
int n, m=-1; int n, m=-1;
char *output; char *output;
if (args) // Pyston change:
if (!PyArg_ParseTuple(args, "|i:readline", &m)) return NULL; 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( (n=IO_creadline((PyObject*)self,&output)) < 0) return NULL;
if (m >= 0 && m < n) { if (m >= 0 && m < n) {
...@@ -514,7 +515,7 @@ static struct PyMethodDef O_methods[] = { ...@@ -514,7 +515,7 @@ static struct PyMethodDef O_methods[] = {
{"getvalue", (PyCFunction)IO_getval, METH_VARARGS, IO_getval__doc__}, {"getvalue", (PyCFunction)IO_getval, METH_VARARGS, IO_getval__doc__},
{"isatty", (PyCFunction)IO_isatty, METH_NOARGS, IO_isatty__doc__}, {"isatty", (PyCFunction)IO_isatty, METH_NOARGS, IO_isatty__doc__},
{"read", (PyCFunction)IO_read, METH_VARARGS, IO_read__doc__}, {"read", (PyCFunction)IO_read, METH_VARARGS, IO_read__doc__},
{"readline", (PyCFunction)IO_readline, METH_VARARGS, IO_readline__doc__}, {"readline", (PyCFunction)IO_readline, /* Pyston change: */ METH_O | METH_D1, IO_readline__doc__},
{"readlines", (PyCFunction)IO_readlines,METH_VARARGS, IO_readlines__doc__}, {"readlines", (PyCFunction)IO_readlines,METH_VARARGS, IO_readlines__doc__},
{"reset", (PyCFunction)IO_reset, METH_NOARGS, IO_reset__doc__}, {"reset", (PyCFunction)IO_reset, METH_NOARGS, IO_reset__doc__},
{"seek", (PyCFunction)IO_seek, METH_VARARGS, IO_seek__doc__}, {"seek", (PyCFunction)IO_seek, METH_VARARGS, IO_seek__doc__},
...@@ -621,7 +622,7 @@ static struct PyMethodDef I_methods[] = { ...@@ -621,7 +622,7 @@ static struct PyMethodDef I_methods[] = {
{"getvalue", (PyCFunction)IO_getval, METH_VARARGS, IO_getval__doc__}, {"getvalue", (PyCFunction)IO_getval, METH_VARARGS, IO_getval__doc__},
{"isatty", (PyCFunction)IO_isatty, METH_NOARGS, IO_isatty__doc__}, {"isatty", (PyCFunction)IO_isatty, METH_NOARGS, IO_isatty__doc__},
{"read", (PyCFunction)IO_read, METH_VARARGS, IO_read__doc__}, {"read", (PyCFunction)IO_read, METH_VARARGS, IO_read__doc__},
{"readline", (PyCFunction)IO_readline, METH_VARARGS, IO_readline__doc__}, {"readline", (PyCFunction)IO_readline, /* Pyston change: */ METH_O | METH_D1, IO_readline__doc__},
{"readlines", (PyCFunction)IO_readlines,METH_VARARGS, IO_readlines__doc__}, {"readlines", (PyCFunction)IO_readlines,METH_VARARGS, IO_readlines__doc__},
{"reset", (PyCFunction)IO_reset, METH_NOARGS, IO_reset__doc__}, {"reset", (PyCFunction)IO_reset, METH_NOARGS, IO_reset__doc__},
{"seek", (PyCFunction)IO_seek, METH_VARARGS, IO_seek__doc__}, {"seek", (PyCFunction)IO_seek, METH_VARARGS, IO_seek__doc__},
......
...@@ -569,8 +569,7 @@ float_argument_error(PyObject *arg) ...@@ -569,8 +569,7 @@ float_argument_error(PyObject *arg)
return 0; return 0;
} }
int _PyArg_ParseSingle_SizeT(PyObject* obj, int arg_idx, const char* fname, const char* format, ...) { int vgetsingle(PyObject* obj, int arg_idx, const char* fname, const char* format, va_list *v_pa, int flags) {
va_list va;
char* msg; char* msg;
char msgbuf[256]; char msgbuf[256];
...@@ -582,9 +581,7 @@ int _PyArg_ParseSingle_SizeT(PyObject* obj, int arg_idx, const char* fname, cons ...@@ -582,9 +581,7 @@ int _PyArg_ParseSingle_SizeT(PyObject* obj, int arg_idx, const char* fname, cons
assert(format[1] != '*'); // would need to pass a non-null freelist assert(format[1] != '*'); // would need to pass a non-null freelist
assert(format[0] != 'e'); // would need to pass a non-null freelist assert(format[0] != 'e'); // would need to pass a non-null freelist
va_start(va, format); msg = convertsimple(obj, &format, v_pa, flags, msgbuf, sizeof(msgbuf), NULL);
msg = convertsimple(obj, &format, &va, FLAG_SIZE_T, msgbuf, sizeof(msgbuf), NULL);
va_end(va);
if (msg) { if (msg) {
int levels[1]; int levels[1];
...@@ -598,6 +595,26 @@ int _PyArg_ParseSingle_SizeT(PyObject* obj, int arg_idx, const char* fname, cons ...@@ -598,6 +595,26 @@ int _PyArg_ParseSingle_SizeT(PyObject* obj, int arg_idx, const char* fname, cons
return 1; return 1;
} }
int PyArg_ParseSingle(PyObject* obj, int arg_idx, const char* fname, const char* format, ...) {
va_list va;
va_start(va, format);
int r = vgetsingle(obj, arg_idx, fname, format, &va, 0);
va_end(va);
return r;
}
int _PyArg_ParseSingle_SizeT(PyObject* obj, int arg_idx, const char* fname, const char* format, ...) {
va_list va;
va_start(va, format);
int r = vgetsingle(obj, arg_idx, fname, format, &va, FLAG_SIZE_T);
va_end(va);
return r;
}
/* Convert a non-tuple argument. Return NULL if conversion went OK, /* Convert a non-tuple argument. Return NULL if conversion went OK,
or a string with a message describing the failure. The message is or a string with a message describing the failure. The message is
formatted as "must be <desired type>, not <actual type>". formatted as "must be <desired type>, not <actual type>".
......
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