diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-06-12 02:07:12 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-06-12 02:07:12 (GMT) |
commit | 680bf1afe89c864d6cf04a37ce1b3b2c1d60072f (patch) | |
tree | 8d688b42e8389e539773d4ab158020b0890272d7 /Modules | |
parent | 2c3ac6b8757f8fc1dacf6aeaa9a9518d8729d52b (diff) | |
download | cpython-680bf1afe89c864d6cf04a37ce1b3b2c1d60072f.zip cpython-680bf1afe89c864d6cf04a37ce1b3b2c1d60072f.tar.gz cpython-680bf1afe89c864d6cf04a37ce1b3b2c1d60072f.tar.bz2 |
move to a naming scheme with all lowercase and underscores
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/_iomodule.c | 8 | ||||
-rw-r--r-- | Modules/_io/_iomodule.h | 8 | ||||
-rw-r--r-- | Modules/_io/bufferedio.c | 604 | ||||
-rw-r--r-- | Modules/_io/bytesio.c | 60 | ||||
-rw-r--r-- | Modules/_io/fileio.c | 64 | ||||
-rw-r--r-- | Modules/_io/iobase.c | 182 | ||||
-rw-r--r-- | Modules/_io/stringio.c | 58 | ||||
-rw-r--r-- | Modules/_io/textio.c | 341 |
8 files changed, 660 insertions, 665 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index ba653d6..02776f3 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -94,7 +94,7 @@ PyDoc_STRVAR(module_doc, */ static int -BlockingIOError_init(PyBlockingIOErrorObject *self, PyObject *args, +blockingioerror_init(PyBlockingIOErrorObject *self, PyObject *args, PyObject *kwds) { PyObject *myerrno = NULL, *strerror = NULL; @@ -123,7 +123,7 @@ BlockingIOError_init(PyBlockingIOErrorObject *self, PyObject *args, return 0; } -static PyMemberDef BlockingIOError_members[] = { +static PyMemberDef blockingioerror_members[] = { {"characters_written", T_PYSSIZET, offsetof(PyBlockingIOErrorObject, written), 0}, {NULL} /* Sentinel */ }; @@ -158,14 +158,14 @@ static PyTypeObject _PyExc_BlockingIOError = { 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ - BlockingIOError_members, /* tp_members */ + blockingioerror_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - (initproc)BlockingIOError_init, /* tp_init */ + (initproc)blockingioerror_init, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ }; diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h index ef7248a..bc0e452 100644 --- a/Modules/_io/_iomodule.h +++ b/Modules/_io/_iomodule.h @@ -23,10 +23,10 @@ extern PyTypeObject PyIncrementalNewlineDecoder_Type; * with args=NULL, and return a new reference. * BUT when args=Py_True is passed, they return a borrowed reference. */ -extern PyObject* _PyIOBase_checkReadable(PyObject *self, PyObject *args); -extern PyObject* _PyIOBase_checkWritable(PyObject *self, PyObject *args); -extern PyObject* _PyIOBase_checkSeekable(PyObject *self, PyObject *args); -extern PyObject* _PyIOBase_checkClosed(PyObject *self, PyObject *args); +extern PyObject* _PyIOBase_check_readable(PyObject *self, PyObject *args); +extern PyObject* _PyIOBase_check_writable(PyObject *self, PyObject *args); +extern PyObject* _PyIOBase_check_seekable(PyObject *self, PyObject *args); +extern PyObject* _PyIOBase_check_closed(PyObject *self, PyObject *args); /* Helper for finalization. This function will revive an object ready to be deallocated and try to diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 034fe51..98f8413 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -16,7 +16,7 @@ /* * BufferedIOBase class, inherits from IOBase. */ -PyDoc_STRVAR(BufferedIOBase_doc, +PyDoc_STRVAR(bufferediobase_doc, "Base class for buffered IO objects.\n" "\n" "The main difference with RawIOBase is that the read() method\n" @@ -33,7 +33,7 @@ PyDoc_STRVAR(BufferedIOBase_doc, ); static PyObject * -BufferedIOBase_readinto(PyObject *self, PyObject *args) +bufferediobase_readinto(PyObject *self, PyObject *args) { Py_buffer buf; Py_ssize_t len; @@ -67,25 +67,25 @@ BufferedIOBase_readinto(PyObject *self, PyObject *args) } static PyObject * -BufferedIOBase_unsupported(const char *message) +bufferediobase_unsupported(const char *message) { PyErr_SetString(IO_STATE->unsupported_operation, message); return NULL; } -PyDoc_STRVAR(BufferedIOBase_detach_doc, +PyDoc_STRVAR(bufferediobase_detach_doc, "Disconnect this buffer from its underlying raw stream and return it.\n" "\n" "After the raw stream has been detached, the buffer is in an unusable\n" "state.\n"); static PyObject * -BufferedIOBase_detach(PyObject *self) +bufferediobase_detach(PyObject *self) { - return BufferedIOBase_unsupported("detach"); + return bufferediobase_unsupported("detach"); } -PyDoc_STRVAR(BufferedIOBase_read_doc, +PyDoc_STRVAR(bufferediobase_read_doc, "Read and return up to n bytes.\n" "\n" "If the argument is omitted, None, or negative, reads and\n" @@ -104,12 +104,12 @@ PyDoc_STRVAR(BufferedIOBase_read_doc, "mode and no data is available at the moment.\n"); static PyObject * -BufferedIOBase_read(PyObject *self, PyObject *args) +bufferediobase_read(PyObject *self, PyObject *args) { - return BufferedIOBase_unsupported("read"); + return bufferediobase_unsupported("read"); } -PyDoc_STRVAR(BufferedIOBase_read1_doc, +PyDoc_STRVAR(bufferediobase_read1_doc, "Read and return up to n bytes, with at most one read() call\n" "to the underlying raw stream. A short result does not imply\n" "that EOF is imminent.\n" @@ -117,12 +117,12 @@ PyDoc_STRVAR(BufferedIOBase_read1_doc, "Returns an empty bytes object on EOF.\n"); static PyObject * -BufferedIOBase_read1(PyObject *self, PyObject *args) +bufferediobase_read1(PyObject *self, PyObject *args) { - return BufferedIOBase_unsupported("read1"); + return bufferediobase_unsupported("read1"); } -PyDoc_STRVAR(BufferedIOBase_write_doc, +PyDoc_STRVAR(bufferediobase_write_doc, "Write the given buffer to the IO stream.\n" "\n" "Returns the number of bytes written, which is never less than\n" @@ -132,18 +132,18 @@ PyDoc_STRVAR(BufferedIOBase_write_doc, "underlying raw stream cannot accept more data at the moment.\n"); static PyObject * -BufferedIOBase_write(PyObject *self, PyObject *args) +bufferediobase_write(PyObject *self, PyObject *args) { - return BufferedIOBase_unsupported("write"); + return bufferediobase_unsupported("write"); } -static PyMethodDef BufferedIOBase_methods[] = { - {"detach", (PyCFunction)BufferedIOBase_detach, METH_NOARGS, BufferedIOBase_detach_doc}, - {"read", BufferedIOBase_read, METH_VARARGS, BufferedIOBase_read_doc}, - {"read1", BufferedIOBase_read1, METH_VARARGS, BufferedIOBase_read1_doc}, - {"readinto", BufferedIOBase_readinto, METH_VARARGS, NULL}, - {"write", BufferedIOBase_write, METH_VARARGS, BufferedIOBase_write_doc}, +static PyMethodDef bufferediobase_methods[] = { + {"detach", (PyCFunction)bufferediobase_detach, METH_NOARGS, bufferediobase_detach_doc}, + {"read", bufferediobase_read, METH_VARARGS, bufferediobase_read_doc}, + {"read1", bufferediobase_read1, METH_VARARGS, bufferediobase_read1_doc}, + {"readinto", bufferediobase_readinto, METH_VARARGS, NULL}, + {"write", bufferediobase_write, METH_VARARGS, bufferediobase_write_doc}, {NULL, NULL} }; @@ -168,14 +168,14 @@ PyTypeObject PyBufferedIOBase_Type = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - BufferedIOBase_doc, /* tp_doc */ + bufferediobase_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - BufferedIOBase_methods, /* tp_methods */ + bufferediobase_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ &PyIOBase_Type, /* tp_base */ @@ -231,7 +231,7 @@ typedef struct { PyObject *dict; PyObject *weakreflist; -} BufferedObject; +} buffered; /* Implementation notes: @@ -245,19 +245,18 @@ typedef struct { * The absolute position of the raw stream is cached, if possible, in the `abs_pos` member. It must be updated every time an operation is done on the raw stream. If not sure, it can be reinitialized by calling - _Buffered_raw_tell(), which queries the raw stream (_Buffered_raw_seek() + _buffered_raw_tell(), which queries the raw stream (_buffered_raw_seek() also does it). To read it, use RAW_TELL(). - * Three helpers, _BufferedReader_raw_read, _BufferedWriter_raw_write and - _BufferedWriter_flush_unlocked do a lot of useful housekeeping. + * Three helpers, _bufferedreader_raw_read, _bufferedwriter_raw_write and + _bufferedwriter_flush_unlocked do a lot of useful housekeeping. NOTE: we should try to maintain block alignment of reads and writes to the raw stream (according to the buffer size), but for now it is only done in read() and friends. - XXX: method naming is a bit messy. */ -/* These macros protect the BufferedObject against concurrent operations. */ +/* These macros protect the buffered object against concurrent operations. */ #ifdef WITH_THREAD #define ENTER_BUFFERED(self) \ @@ -299,7 +298,7 @@ typedef struct { #define IS_CLOSED(self) \ (self->fast_closed_checks \ ? _PyFileIO_closed(self->raw) \ - : BufferedIOMixin_closed(self)) + : buffered_closed(self)) #define CHECK_CLOSED(self, error_msg) \ if (IS_CLOSED(self)) { \ @@ -330,7 +329,7 @@ typedef struct { && self->raw_pos >= 0) ? self->raw_pos - self->pos : 0) #define RAW_TELL(self) \ - (self->abs_pos != -1 ? self->abs_pos : _Buffered_raw_tell(self)) + (self->abs_pos != -1 ? self->abs_pos : _buffered_raw_tell(self)) #define MINUS_LAST_BLOCK(self, size) \ (self->buffer_mask ? \ @@ -339,7 +338,7 @@ typedef struct { static void -BufferedObject_dealloc(BufferedObject *self) +buffered_dealloc(buffered *self) { if (self->ok && _PyIOBase_finalize((PyObject *) self) < 0) return; @@ -363,7 +362,7 @@ BufferedObject_dealloc(BufferedObject *self) } static int -Buffered_traverse(BufferedObject *self, visitproc visit, void *arg) +buffered_traverse(buffered *self, visitproc visit, void *arg) { Py_VISIT(self->raw); Py_VISIT(self->dict); @@ -371,7 +370,7 @@ Buffered_traverse(BufferedObject *self, visitproc visit, void *arg) } static int -Buffered_clear(BufferedObject *self) +buffered_clear(buffered *self) { if (self->ok && _PyIOBase_finalize((PyObject *) self) < 0) return -1; @@ -390,14 +389,14 @@ Buffered_clear(BufferedObject *self) /* Flush and close */ static PyObject * -BufferedIOMixin_flush(BufferedObject *self, PyObject *args) +buffered_simple_flush(buffered *self, PyObject *args) { CHECK_INITIALIZED(self) return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_flush, NULL); } static int -BufferedIOMixin_closed(BufferedObject *self) +buffered_closed(buffered *self) { int closed; PyObject *res; @@ -411,14 +410,14 @@ BufferedIOMixin_closed(BufferedObject *self) } static PyObject * -BufferedIOMixin_closed_get(BufferedObject *self, void *context) +buffered_closed_get(buffered *self, void *context) { CHECK_INITIALIZED(self) return PyObject_GetAttr(self->raw, _PyIO_str_closed); } static PyObject * -BufferedIOMixin_close(BufferedObject *self, PyObject *args) +buffered_close(buffered *self, PyObject *args) { PyObject *res = NULL; int r; @@ -426,7 +425,7 @@ BufferedIOMixin_close(BufferedObject *self, PyObject *args) CHECK_INITIALIZED(self) ENTER_BUFFERED(self) - r = BufferedIOMixin_closed(self); + r = buffered_closed(self); if (r < 0) goto end; if (r > 0) { @@ -457,7 +456,7 @@ end: /* detach */ static PyObject * -BufferedIOMixin_detach(BufferedObject *self, PyObject *args) +buffered_detach(buffered *self, PyObject *args) { PyObject *raw, *res; CHECK_INITIALIZED(self) @@ -475,35 +474,35 @@ BufferedIOMixin_detach(BufferedObject *self, PyObject *args) /* Inquiries */ static PyObject * -BufferedIOMixin_seekable(BufferedObject *self, PyObject *args) +buffered_seekable(buffered *self, PyObject *args) { CHECK_INITIALIZED(self) return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_seekable, NULL); } static PyObject * -BufferedIOMixin_readable(BufferedObject *self, PyObject *args) +buffered_readable(buffered *self, PyObject *args) { CHECK_INITIALIZED(self) return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_readable, NULL); } static PyObject * -BufferedIOMixin_writable(BufferedObject *self, PyObject *args) +buffered_writable(buffered *self, PyObject *args) { CHECK_INITIALIZED(self) return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_writable, NULL); } static PyObject * -BufferedIOMixin_name_get(BufferedObject *self, void *context) +buffered_name_get(buffered *self, void *context) { CHECK_INITIALIZED(self) return PyObject_GetAttrString(self->raw, "name"); } static PyObject * -BufferedIOMixin_mode_get(BufferedObject *self, void *context) +buffered_mode_get(buffered *self, void *context) { CHECK_INITIALIZED(self) return PyObject_GetAttrString(self->raw, "mode"); @@ -512,14 +511,14 @@ BufferedIOMixin_mode_get(BufferedObject *self, void *context) /* Lower-level APIs */ static PyObject * -BufferedIOMixin_fileno(BufferedObject *self, PyObject *args) +buffered_fileno(buffered *self, PyObject *args) { CHECK_INITIALIZED(self) return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_fileno, NULL); } static PyObject * -BufferedIOMixin_isatty(BufferedObject *self, PyObject *args) +buffered_isatty(buffered *self, PyObject *args) { CHECK_INITIALIZED(self) return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_isatty, NULL); @@ -528,21 +527,21 @@ BufferedIOMixin_isatty(BufferedObject *self, PyObject *args) /* Forward decls */ static PyObject * -_BufferedWriter_flush_unlocked(BufferedObject *, int); +_bufferedwriter_flush_unlocked(buffered *, int); static Py_ssize_t -_BufferedReader_fill_buffer(BufferedObject *self); +_bufferedreader_fill_buffer(buffered *self); static void -_BufferedReader_reset_buf(BufferedObject *self); +_bufferedreader_reset_buf(buffered *self); static void -_BufferedWriter_reset_buf(BufferedObject *self); +_bufferedwriter_reset_buf(buffered *self); static PyObject * -_BufferedReader_peek_unlocked(BufferedObject *self, Py_ssize_t); +_bufferedreader_peek_unlocked(buffered *self, Py_ssize_t); static PyObject * -_BufferedReader_read_all(BufferedObject *self); +_bufferedreader_read_all(buffered *self); static PyObject * -_BufferedReader_read_fast(BufferedObject *self, Py_ssize_t); +_bufferedreader_read_fast(buffered *self, Py_ssize_t); static PyObject * -_BufferedReader_read_generic(BufferedObject *self, Py_ssize_t); +_bufferedreader_read_generic(buffered *self, Py_ssize_t); /* @@ -552,7 +551,7 @@ _BufferedReader_read_generic(BufferedObject *self, Py_ssize_t); /* Returns the address of the `written` member if a BlockingIOError was raised, NULL otherwise. The error is always re-raised. */ static Py_ssize_t * -_Buffered_check_blocking_error(void) +_buffered_check_blocking_error(void) { PyObject *t, *v, *tb; PyBlockingIOErrorObject *err; @@ -569,7 +568,7 @@ _Buffered_check_blocking_error(void) } static Py_off_t -_Buffered_raw_tell(BufferedObject *self) +_buffered_raw_tell(buffered *self) { Py_off_t n; PyObject *res; @@ -589,7 +588,7 @@ _Buffered_raw_tell(BufferedObject *self) } static Py_off_t -_Buffered_raw_seek(BufferedObject *self, Py_off_t target, int whence) +_buffered_raw_seek(buffered *self, Py_off_t target, int whence) { PyObject *res, *posobj, *whenceobj; Py_off_t n; @@ -621,7 +620,7 @@ _Buffered_raw_seek(BufferedObject *self, Py_off_t target, int whence) } static int -_Buffered_init(BufferedObject *self) +_buffered_init(buffered *self) { Py_ssize_t n; if (self->buffer_size <= 0) { @@ -651,7 +650,7 @@ _Buffered_init(BufferedObject *self) self->buffer_mask = self->buffer_size - 1; else self->buffer_mask = 0; - if (_Buffered_raw_tell(self) == -1) + if (_buffered_raw_tell(self) == -1) PyErr_Clear(); return 0; } @@ -661,7 +660,7 @@ _Buffered_init(BufferedObject *self) */ static PyObject * -Buffered_flush(BufferedObject *self, PyObject *args) +buffered_flush(buffered *self, PyObject *args) { PyObject *res; @@ -669,15 +668,15 @@ Buffered_flush(BufferedObject *self, PyObject *args) CHECK_CLOSED(self, "flush of closed file") ENTER_BUFFERED(self) - res = _BufferedWriter_flush_unlocked(self, 0); + res = _bufferedwriter_flush_unlocked(self, 0); if (res != NULL && self->readable) { /* Rewind the raw stream so that its position corresponds to the current logical position. */ Py_off_t n; - n = _Buffered_raw_seek(self, -RAW_OFFSET(self), 1); + n = _buffered_raw_seek(self, -RAW_OFFSET(self), 1); if (n == -1) Py_CLEAR(res); - _BufferedReader_reset_buf(self); + _bufferedreader_reset_buf(self); } LEAVE_BUFFERED(self) @@ -685,7 +684,7 @@ Buffered_flush(BufferedObject *self, PyObject *args) } static PyObject * -Buffered_peek(BufferedObject *self, PyObject *args) +buffered_peek(buffered *self, PyObject *args) { Py_ssize_t n = 0; PyObject *res = NULL; @@ -698,12 +697,12 @@ Buffered_peek(BufferedObject *self, PyObject *args) ENTER_BUFFERED(self) if (self->writable) { - res = _BufferedWriter_flush_unlocked(self, 1); + res = _bufferedwriter_flush_unlocked(self, 1); if (res == NULL) goto end; Py_CLEAR(res); } - res = _BufferedReader_peek_unlocked(self, n); + res = _bufferedreader_peek_unlocked(self, n); end: LEAVE_BUFFERED(self) @@ -711,7 +710,7 @@ end: } static PyObject * -Buffered_read(BufferedObject *self, PyObject *args) +buffered_read(buffered *self, PyObject *args) { Py_ssize_t n = -1; PyObject *res; @@ -731,15 +730,15 @@ Buffered_read(BufferedObject *self, PyObject *args) if (n == -1) { /* The number of bytes is unspecified, read until the end of stream */ ENTER_BUFFERED(self) - res = _BufferedReader_read_all(self); + res = _bufferedreader_read_all(self); LEAVE_BUFFERED(self) } else { - res = _BufferedReader_read_fast(self, n); + res = _bufferedreader_read_fast(self, n); if (res == Py_None) { Py_DECREF(res); ENTER_BUFFERED(self) - res = _BufferedReader_read_generic(self, n); + res = _bufferedreader_read_generic(self, n); LEAVE_BUFFERED(self) } } @@ -748,7 +747,7 @@ Buffered_read(BufferedObject *self, PyObject *args) } static PyObject * -Buffered_read1(BufferedObject *self, PyObject *args) +buffered_read1(buffered *self, PyObject *args) { Py_ssize_t n, have, r; PyObject *res = NULL; @@ -769,7 +768,7 @@ Buffered_read1(BufferedObject *self, PyObject *args) ENTER_BUFFERED(self) if (self->writable) { - res = _BufferedWriter_flush_unlocked(self, 1); + res = _bufferedwriter_flush_unlocked(self, 1); if (res == NULL) goto end; Py_CLEAR(res); @@ -795,8 +794,8 @@ Buffered_read1(BufferedObject *self, PyObject *args) } /* Fill the buffer from the raw stream, and copy it to the result. */ - _BufferedReader_reset_buf(self); - r = _BufferedReader_fill_buffer(self); + _bufferedreader_reset_buf(self); + r = _bufferedreader_fill_buffer(self); if (r == -1) goto end; if (r == -2) @@ -814,7 +813,7 @@ end: } static PyObject * -Buffered_readinto(BufferedObject *self, PyObject *args) +buffered_readinto(buffered *self, PyObject *args) { PyObject *res = NULL; @@ -823,20 +822,20 @@ Buffered_readinto(BufferedObject *self, PyObject *args) /* TODO: use raw.readinto() instead! */ if (self->writable) { ENTER_BUFFERED(self) - res = _BufferedWriter_flush_unlocked(self, 0); + res = _bufferedwriter_flush_unlocked(self, 0); LEAVE_BUFFERED(self) if (res == NULL) goto end; Py_DECREF(res); } - res = BufferedIOBase_readinto((PyObject *)self, args); + res = bufferediobase_readinto((PyObject *)self, args); end: return res; } static PyObject * -_Buffered_readline(BufferedObject *self, Py_ssize_t limit) +_buffered_readline(buffered *self, Py_ssize_t limit) { PyObject *res = NULL; PyObject *chunks = NULL; @@ -870,7 +869,7 @@ _Buffered_readline(BufferedObject *self, Py_ssize_t limit) /* Now we try to get some more from the raw stream */ if (self->writable) { - res = _BufferedWriter_flush_unlocked(self, 1); + res = _bufferedwriter_flush_unlocked(self, 1); if (res == NULL) goto end; Py_CLEAR(res); @@ -893,8 +892,8 @@ _Buffered_readline(BufferedObject *self, Py_ssize_t limit) } for (;;) { - _BufferedReader_reset_buf(self); - n = _BufferedReader_fill_buffer(self); + _bufferedreader_reset_buf(self); + n = _bufferedreader_fill_buffer(self); if (n == -1) goto end; if (n <= 0) @@ -945,7 +944,7 @@ end_unlocked: } static PyObject * -Buffered_readline(BufferedObject *self, PyObject *args) +buffered_readline(buffered *self, PyObject *args) { Py_ssize_t limit = -1; @@ -954,17 +953,17 @@ Buffered_readline(BufferedObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "|n:readline", &limit)) { return NULL; } - return _Buffered_readline(self, limit); + return _buffered_readline(self, limit); } static PyObject * -Buffered_tell(BufferedObject *self, PyObject *args) +buffered_tell(buffered *self, PyObject *args) { Py_off_t pos; CHECK_INITIALIZED(self) - pos = _Buffered_raw_tell(self); + pos = _buffered_raw_tell(self); if (pos == -1) return NULL; pos -= RAW_OFFSET(self); @@ -973,7 +972,7 @@ Buffered_tell(BufferedObject *self, PyObject *args) } static PyObject * -Buffered_seek(BufferedObject *self, PyObject *args) +buffered_seek(buffered *self, PyObject *args) { Py_off_t target, n; int whence = 0; @@ -1022,23 +1021,23 @@ Buffered_seek(BufferedObject *self, PyObject *args) /* Fallback: invoke raw seek() method and clear buffer */ if (self->writable) { - res = _BufferedWriter_flush_unlocked(self, 0); + res = _bufferedwriter_flush_unlocked(self, 0); if (res == NULL) goto end; Py_CLEAR(res); - _BufferedWriter_reset_buf(self); + _bufferedwriter_reset_buf(self); } /* TODO: align on block boundary and read buffer if needed? */ if (whence == 1) target -= RAW_OFFSET(self); - n = _Buffered_raw_seek(self, target, whence); + n = _buffered_raw_seek(self, target, whence); if (n == -1) goto end; self->raw_pos = -1; res = PyLong_FromOff_t(n); if (res != NULL && self->readable) - _BufferedReader_reset_buf(self); + _bufferedreader_reset_buf(self); end: LEAVE_BUFFERED(self) @@ -1046,7 +1045,7 @@ end: } static PyObject * -Buffered_truncate(BufferedObject *self, PyObject *args) +buffered_truncate(buffered *self, PyObject *args) { PyObject *pos = Py_None; PyObject *res = NULL; @@ -1059,7 +1058,7 @@ Buffered_truncate(BufferedObject *self, PyObject *args) ENTER_BUFFERED(self) if (self->writable) { - res = _BufferedWriter_flush_unlocked(self, 0); + res = _bufferedwriter_flush_unlocked(self, 0); if (res == NULL) goto end; Py_CLEAR(res); @@ -1068,16 +1067,16 @@ Buffered_truncate(BufferedObject *self, PyObject *args) if (pos == Py_None) { /* Rewind the raw stream so that its position corresponds to the current logical position. */ - if (_Buffered_raw_seek(self, -RAW_OFFSET(self), 1) == -1) + if (_buffered_raw_seek(self, -RAW_OFFSET(self), 1) == -1) goto end; } - _BufferedReader_reset_buf(self); + _bufferedreader_reset_buf(self); } res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_truncate, pos, NULL); if (res == NULL) goto end; /* Reset cached position */ - if (_Buffered_raw_tell(self) == -1) + if (_buffered_raw_tell(self) == -1) PyErr_Clear(); end: @@ -1086,7 +1085,7 @@ end: } static PyObject * -Buffered_iternext(BufferedObject *self) +buffered_iternext(buffered *self) { PyObject *line; PyTypeObject *tp; @@ -1097,7 +1096,7 @@ Buffered_iternext(BufferedObject *self) if (tp == &PyBufferedReader_Type || tp == &PyBufferedRandom_Type) { /* Skip method call overhead for speed */ - line = _Buffered_readline(self, -1); + line = _buffered_readline(self, -1); } else { line = PyObject_CallMethodObjArgs((PyObject *)self, @@ -1124,7 +1123,7 @@ Buffered_iternext(BufferedObject *self) } static PyObject * -Buffered_repr(BufferedObject *self) +buffered_repr(buffered *self) { PyObject *nameobj, *res; @@ -1148,16 +1147,16 @@ Buffered_repr(BufferedObject *self) * class BufferedReader */ -PyDoc_STRVAR(BufferedReader_doc, +PyDoc_STRVAR(bufferedreader_doc, "Create a new buffered reader using the given readable raw IO object."); -static void _BufferedReader_reset_buf(BufferedObject *self) +static void _bufferedreader_reset_buf(buffered *self) { self->read_end = -1; } static int -BufferedReader_init(BufferedObject *self, PyObject *args, PyObject *kwds) +bufferedreader_init(buffered *self, PyObject *args, PyObject *kwds) { char *kwlist[] = {"raw", "buffer_size", NULL}; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; @@ -1171,7 +1170,7 @@ BufferedReader_init(BufferedObject *self, PyObject *args, PyObject *kwds) return -1; } - if (_PyIOBase_checkReadable(raw, Py_True) == NULL) + if (_PyIOBase_check_readable(raw, Py_True) == NULL) return -1; Py_CLEAR(self->raw); @@ -1181,9 +1180,9 @@ BufferedReader_init(BufferedObject *self, PyObject *args, PyObject *kwds) self->readable = 1; self->writable = 0; - if (_Buffered_init(self) < 0) + if (_buffered_init(self) < 0) return -1; - _BufferedReader_reset_buf(self); + _bufferedreader_reset_buf(self); self->fast_closed_checks = (Py_TYPE(self) == &PyBufferedReader_Type && Py_TYPE(raw) == &PyFileIO_Type); @@ -1193,7 +1192,7 @@ BufferedReader_init(BufferedObject *self, PyObject *args, PyObject *kwds) } static Py_ssize_t -_BufferedReader_raw_read(BufferedObject *self, char *start, Py_ssize_t len) +_bufferedreader_raw_read(buffered *self, char *start, Py_ssize_t len) { Py_buffer buf; PyObject *memobj, *res; @@ -1227,7 +1226,7 @@ _BufferedReader_raw_read(BufferedObject *self, char *start, Py_ssize_t len) } static Py_ssize_t -_BufferedReader_fill_buffer(BufferedObject *self) +_bufferedreader_fill_buffer(buffered *self) { Py_ssize_t start, len, n; if (VALID_READ_BUFFER(self)) @@ -1235,7 +1234,7 @@ _BufferedReader_fill_buffer(BufferedObject *self) else start = 0; len = self->buffer_size - start; - n = _BufferedReader_raw_read(self, self->buffer + start, len); + n = _bufferedreader_raw_read(self, self->buffer + start, len); if (n <= 0) return n; self->read_end = start + n; @@ -1244,7 +1243,7 @@ _BufferedReader_fill_buffer(BufferedObject *self) } static PyObject * -_BufferedReader_read_all(BufferedObject *self) +_bufferedreader_read_all(buffered *self) { Py_ssize_t current_size; PyObject *res, *data = NULL; @@ -1263,10 +1262,10 @@ _BufferedReader_read_all(BufferedObject *self) return NULL; } } - _BufferedReader_reset_buf(self); + _bufferedreader_reset_buf(self); /* We're going past the buffer's bounds, flush it */ if (self->writable) { - res = _BufferedWriter_flush_unlocked(self, 1); + res = _bufferedwriter_flush_unlocked(self, 1); if (res == NULL) { Py_DECREF(chunks); return NULL; @@ -1316,7 +1315,7 @@ _BufferedReader_read_all(BufferedObject *self) /* Read n bytes from the buffer if it can, otherwise return None. This function is simple enough that it can run unlocked. */ static PyObject * -_BufferedReader_read_fast(BufferedObject *self, Py_ssize_t n) +_bufferedreader_read_fast(buffered *self, Py_ssize_t n) { Py_ssize_t current_size; @@ -1335,7 +1334,7 @@ _BufferedReader_read_fast(BufferedObject *self, Py_ssize_t n) * or until an EOF occurs or until read() would block. */ static PyObject * -_BufferedReader_read_generic(BufferedObject *self, Py_ssize_t n) +_bufferedreader_read_generic(buffered *self, Py_ssize_t n) { PyObject *res = NULL; Py_ssize_t current_size, remaining, written; @@ -1343,7 +1342,7 @@ _BufferedReader_read_generic(BufferedObject *self, Py_ssize_t n) current_size = Py_SAFE_DOWNCAST(READAHEAD(self), Py_off_t, Py_ssize_t); if (n <= current_size) - return _BufferedReader_read_fast(self, n); + return _bufferedreader_read_fast(self, n); res = PyBytes_FromStringAndSize(NULL, n); if (res == NULL) @@ -1356,14 +1355,14 @@ _BufferedReader_read_generic(BufferedObject *self, Py_ssize_t n) remaining -= current_size; written += current_size; } - _BufferedReader_reset_buf(self); + _bufferedreader_reset_buf(self); while (remaining > 0) { /* We want to read a whole block at the end into buffer. If we had readv() we could do this in one pass. */ Py_ssize_t r = MINUS_LAST_BLOCK(self, remaining); if (r == 0) break; - r = _BufferedReader_raw_read(self, out + written, r); + r = _bufferedreader_raw_read(self, out + written, r); if (r == -1) goto error; if (r == 0 || r == -2) { @@ -1385,7 +1384,7 @@ _BufferedReader_read_generic(BufferedObject *self, Py_ssize_t n) self->raw_pos = 0; self->read_end = 0; while (self->read_end < self->buffer_size) { - Py_ssize_t r = _BufferedReader_fill_buffer(self); + Py_ssize_t r = _bufferedreader_fill_buffer(self); if (r == -1) goto error; if (r == 0 || r == -2) { @@ -1423,7 +1422,7 @@ error: } static PyObject * -_BufferedReader_peek_unlocked(BufferedObject *self, Py_ssize_t n) +_bufferedreader_peek_unlocked(buffered *self, Py_ssize_t n) { Py_ssize_t have, r; @@ -1439,8 +1438,8 @@ _BufferedReader_peek_unlocked(BufferedObject *self, Py_ssize_t n) } /* Fill the buffer from the raw stream, and copy it to the result. */ - _BufferedReader_reset_buf(self); - r = _BufferedReader_fill_buffer(self); + _bufferedreader_reset_buf(self); + r = _bufferedreader_fill_buffer(self); if (r == -1) return NULL; if (r == -2) @@ -1449,36 +1448,36 @@ _BufferedReader_peek_unlocked(BufferedObject *self, Py_ssize_t n) return PyBytes_FromStringAndSize(self->buffer, r); } -static PyMethodDef BufferedReader_methods[] = { +static PyMethodDef bufferedreader_methods[] = { /* BufferedIOMixin methods */ - {"detach", (PyCFunction)BufferedIOMixin_detach, METH_NOARGS}, - {"flush", (PyCFunction)BufferedIOMixin_flush, METH_NOARGS}, - {"close", (PyCFunction)BufferedIOMixin_close, METH_NOARGS}, - {"seekable", (PyCFunction)BufferedIOMixin_seekable, METH_NOARGS}, - {"readable", (PyCFunction)BufferedIOMixin_readable, METH_NOARGS}, - {"writable", (PyCFunction)BufferedIOMixin_writable, METH_NOARGS}, - {"fileno", (PyCFunction)BufferedIOMixin_fileno, METH_NOARGS}, - {"isatty", (PyCFunction)BufferedIOMixin_isatty, METH_NOARGS}, - - {"read", (PyCFunction)Buffered_read, METH_VARARGS}, - {"peek", (PyCFunction)Buffered_peek, METH_VARARGS}, - {"read1", (PyCFunction)Buffered_read1, METH_VARARGS}, - {"readline", (PyCFunction)Buffered_readline, METH_VARARGS}, - {"seek", (PyCFunction)Buffered_seek, METH_VARARGS}, - {"tell", (PyCFunction)Buffered_tell, METH_NOARGS}, - {"truncate", (PyCFunction)Buffered_truncate, METH_VARARGS}, + {"detach", (PyCFunction)buffered_detach, METH_NOARGS}, + {"flush", (PyCFunction)buffered_simple_flush, METH_NOARGS}, + {"close", (PyCFunction)buffered_close, METH_NOARGS}, + {"seekable", (PyCFunction)buffered_seekable, METH_NOARGS}, + {"readable", (PyCFunction)buffered_readable, METH_NOARGS}, + {"writable", (PyCFunction)buffered_writable, METH_NOARGS}, + {"fileno", (PyCFunction)buffered_fileno, METH_NOARGS}, + {"isatty", (PyCFunction)buffered_isatty, METH_NOARGS}, + + {"read", (PyCFunction)buffered_read, METH_VARARGS}, + {"peek", (PyCFunction)buffered_peek, METH_VARARGS}, + {"read1", (PyCFunction)buffered_read1, METH_VARARGS}, + {"readline", (PyCFunction)buffered_readline, METH_VARARGS}, + {"seek", (PyCFunction)buffered_seek, METH_VARARGS}, + {"tell", (PyCFunction)buffered_tell, METH_NOARGS}, + {"truncate", (PyCFunction)buffered_truncate, METH_VARARGS}, {NULL, NULL} }; -static PyMemberDef BufferedReader_members[] = { - {"raw", T_OBJECT, offsetof(BufferedObject, raw), 0}, +static PyMemberDef bufferedreader_members[] = { + {"raw", T_OBJECT, offsetof(buffered, raw), 0}, {NULL} }; -static PyGetSetDef BufferedReader_getset[] = { - {"closed", (getter)BufferedIOMixin_closed_get, NULL, NULL}, - {"name", (getter)BufferedIOMixin_name_get, NULL, NULL}, - {"mode", (getter)BufferedIOMixin_mode_get, NULL, NULL}, +static PyGetSetDef bufferedreader_getset[] = { + {"closed", (getter)buffered_closed_get, NULL, NULL}, + {"name", (getter)buffered_name_get, NULL, NULL}, + {"mode", (getter)buffered_mode_get, NULL, NULL}, {NULL} }; @@ -1486,14 +1485,14 @@ static PyGetSetDef BufferedReader_getset[] = { PyTypeObject PyBufferedReader_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.BufferedReader", /*tp_name*/ - sizeof(BufferedObject), /*tp_basicsize*/ + sizeof(buffered), /*tp_basicsize*/ 0, /*tp_itemsize*/ - (destructor)BufferedObject_dealloc, /*tp_dealloc*/ + (destructor)buffered_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare */ - (reprfunc)Buffered_repr, /*tp_repr*/ + (reprfunc)buffered_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -1505,22 +1504,22 @@ PyTypeObject PyBufferedReader_Type = { 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - BufferedReader_doc, /* tp_doc */ - (traverseproc)Buffered_traverse, /* tp_traverse */ - (inquiry)Buffered_clear, /* tp_clear */ + bufferedreader_doc, /* tp_doc */ + (traverseproc)buffered_traverse, /* tp_traverse */ + (inquiry)buffered_clear, /* tp_clear */ 0, /* tp_richcompare */ - offsetof(BufferedObject, weakreflist), /*tp_weaklistoffset*/ + offsetof(buffered, weakreflist), /*tp_weaklistoffset*/ 0, /* tp_iter */ - (iternextfunc)Buffered_iternext, /* tp_iternext */ - BufferedReader_methods, /* tp_methods */ - BufferedReader_members, /* tp_members */ - BufferedReader_getset, /* tp_getset */ + (iternextfunc)buffered_iternext, /* tp_iternext */ + bufferedreader_methods, /* tp_methods */ + bufferedreader_members, /* tp_members */ + bufferedreader_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(BufferedObject, dict), /* tp_dictoffset */ - (initproc)BufferedReader_init, /* tp_init */ + offsetof(buffered, dict), /* tp_dictoffset */ + (initproc)bufferedreader_init, /* tp_init */ 0, /* tp_alloc */ PyType_GenericNew, /* tp_new */ }; @@ -1539,7 +1538,7 @@ complain_about_max_buffer_size(void) /* * class BufferedWriter */ -PyDoc_STRVAR(BufferedWriter_doc, +PyDoc_STRVAR(bufferedwriter_doc, "A buffer for a writeable sequential RawIO object.\n" "\n" "The constructor creates a BufferedWriter for the given writeable raw\n" @@ -1548,14 +1547,14 @@ PyDoc_STRVAR(BufferedWriter_doc, ); static void -_BufferedWriter_reset_buf(BufferedObject *self) +_bufferedwriter_reset_buf(buffered *self) { self->write_pos = 0; self->write_end = -1; } static int -BufferedWriter_init(BufferedObject *self, PyObject *args, PyObject *kwds) +bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds) { /* TODO: properly deprecate max_buffer_size */ char *kwlist[] = {"raw", "buffer_size", "max_buffer_size", NULL}; @@ -1574,7 +1573,7 @@ BufferedWriter_init(BufferedObject *self, PyObject *args, PyObject *kwds) if (max_buffer_size != -234 && !complain_about_max_buffer_size()) return -1; - if (_PyIOBase_checkWritable(raw, Py_True) == NULL) + if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; Py_CLEAR(self->raw); @@ -1584,9 +1583,9 @@ BufferedWriter_init(BufferedObject *self, PyObject *args, PyObject *kwds) self->writable = 1; self->buffer_size = buffer_size; - if (_Buffered_init(self) < 0) + if (_buffered_init(self) < 0) return -1; - _BufferedWriter_reset_buf(self); + _bufferedwriter_reset_buf(self); self->pos = 0; self->fast_closed_checks = (Py_TYPE(self) == &PyBufferedWriter_Type && @@ -1597,7 +1596,7 @@ BufferedWriter_init(BufferedObject *self, PyObject *args, PyObject *kwds) } static Py_ssize_t -_BufferedWriter_raw_write(BufferedObject *self, char *start, Py_ssize_t len) +_bufferedwriter_raw_write(buffered *self, char *start, Py_ssize_t len) { Py_buffer buf; PyObject *memobj, *res; @@ -1628,7 +1627,7 @@ _BufferedWriter_raw_write(BufferedObject *self, char *start, Py_ssize_t len) /* `restore_pos` is 1 if we need to restore the raw stream position at the end, 0 otherwise. */ static PyObject * -_BufferedWriter_flush_unlocked(BufferedObject *self, int restore_pos) +_bufferedwriter_flush_unlocked(buffered *self, int restore_pos) { Py_ssize_t written = 0; Py_off_t n, rewind; @@ -1638,19 +1637,19 @@ _BufferedWriter_flush_unlocked(BufferedObject *self, int restore_pos) /* First, rewind */ rewind = RAW_OFFSET(self) + (self->pos - self->write_pos); if (rewind != 0) { - n = _Buffered_raw_seek(self, -rewind, 1); + n = _buffered_raw_seek(self, -rewind, 1); if (n < 0) { goto error; } self->raw_pos -= rewind; } while (self->write_pos < self->write_end) { - n = _BufferedWriter_raw_write(self, + n = _bufferedwriter_raw_write(self, self->buffer + self->write_pos, Py_SAFE_DOWNCAST(self->write_end - self->write_pos, Py_off_t, Py_ssize_t)); if (n == -1) { - Py_ssize_t *w = _Buffered_check_blocking_error(); + Py_ssize_t *w = _buffered_check_blocking_error(); if (w == NULL) goto error; self->write_pos += *w; @@ -1668,14 +1667,14 @@ _BufferedWriter_flush_unlocked(BufferedObject *self, int restore_pos) if (restore_pos) { Py_off_t forward = rewind - written; if (forward != 0) { - n = _Buffered_raw_seek(self, forward, 1); + n = _buffered_raw_seek(self, forward, 1); if (n < 0) { goto error; } self->raw_pos += forward; } } - _BufferedWriter_reset_buf(self); + _bufferedwriter_reset_buf(self); end: Py_RETURN_NONE; @@ -1685,7 +1684,7 @@ error: } static PyObject * -BufferedWriter_write(BufferedObject *self, PyObject *args) +bufferedwriter_write(buffered *self, PyObject *args) { PyObject *res = NULL; Py_buffer buf; @@ -1723,13 +1722,13 @@ BufferedWriter_write(BufferedObject *self, PyObject *args) } /* First write the current buffer */ - res = _BufferedWriter_flush_unlocked(self, 0); + res = _bufferedwriter_flush_unlocked(self, 0); if (res == NULL) { - Py_ssize_t *w = _Buffered_check_blocking_error(); + Py_ssize_t *w = _buffered_check_blocking_error(); if (w == NULL) goto error; if (self->readable) - _BufferedReader_reset_buf(self); + _bufferedreader_reset_buf(self); /* Make some place by shifting the buffer. */ assert(VALID_WRITE_BUFFER(self)); memmove(self->buffer, self->buffer + self->write_pos, @@ -1762,10 +1761,10 @@ BufferedWriter_write(BufferedObject *self, PyObject *args) remaining = buf.len; written = 0; while (remaining > self->buffer_size) { - n = _BufferedWriter_raw_write( + n = _bufferedwriter_raw_write( self, (char *) buf.buf + written, buf.len - written); if (n == -1) { - Py_ssize_t *w = _Buffered_check_blocking_error(); + Py_ssize_t *w = _buffered_check_blocking_error(); if (w == NULL) goto error; written += *w; @@ -1788,7 +1787,7 @@ BufferedWriter_write(BufferedObject *self, PyObject *args) remaining -= n; } if (self->readable) - _BufferedReader_reset_buf(self); + _bufferedreader_reset_buf(self); if (remaining > 0) { memcpy(self->buffer, (char *) buf.buf + written, remaining); written += remaining; @@ -1808,33 +1807,33 @@ error: return res; } -static PyMethodDef BufferedWriter_methods[] = { +static PyMethodDef bufferedwriter_methods[] = { /* BufferedIOMixin methods */ - {"close", (PyCFunction)BufferedIOMixin_close, METH_NOARGS}, - {"detach", (PyCFunction)BufferedIOMixin_detach, METH_NOARGS}, - {"seekable", (PyCFunction)BufferedIOMixin_seekable, METH_NOARGS}, - {"readable", (PyCFunction)BufferedIOMixin_readable, METH_NOARGS}, - {"writable", (PyCFunction)BufferedIOMixin_writable, METH_NOARGS}, - {"fileno", (PyCFunction)BufferedIOMixin_fileno, METH_NOARGS}, - {"isatty", (PyCFunction)BufferedIOMixin_isatty, METH_NOARGS}, - - {"write", (PyCFunction)BufferedWriter_write, METH_VARARGS}, - {"truncate", (PyCFunction)Buffered_truncate, METH_VARARGS}, - {"flush", (PyCFunction)Buffered_flush, METH_NOARGS}, - {"seek", (PyCFunction)Buffered_seek, METH_VARARGS}, - {"tell", (PyCFunction)Buffered_tell, METH_NOARGS}, + {"close", (PyCFunction)buffered_close, METH_NOARGS}, + {"detach", (PyCFunction)buffered_detach, METH_NOARGS}, + {"seekable", (PyCFunction)buffered_seekable, METH_NOARGS}, + {"readable", (PyCFunction)buffered_readable, METH_NOARGS}, + {"writable", (PyCFunction)buffered_writable, METH_NOARGS}, + {"fileno", (PyCFunction)buffered_fileno, METH_NOARGS}, + {"isatty", (PyCFunction)buffered_isatty, METH_NOARGS}, + + {"write", (PyCFunction)bufferedwriter_write, METH_VARARGS}, + {"truncate", (PyCFunction)buffered_truncate, METH_VARARGS}, + {"flush", (PyCFunction)buffered_flush, METH_NOARGS}, + {"seek", (PyCFunction)buffered_seek, METH_VARARGS}, + {"tell", (PyCFunction)buffered_tell, METH_NOARGS}, {NULL, NULL} }; -static PyMemberDef BufferedWriter_members[] = { - {"raw", T_OBJECT, offsetof(BufferedObject, raw), 0}, +static PyMemberDef bufferedwriter_members[] = { + {"raw", T_OBJECT, offsetof(buffered, raw), 0}, {NULL} }; -static PyGetSetDef BufferedWriter_getset[] = { - {"closed", (getter)BufferedIOMixin_closed_get, NULL, NULL}, - {"name", (getter)BufferedIOMixin_name_get, NULL, NULL}, - {"mode", (getter)BufferedIOMixin_mode_get, NULL, NULL}, +static PyGetSetDef bufferedwriter_getset[] = { + {"closed", (getter)buffered_closed_get, NULL, NULL}, + {"name", (getter)buffered_name_get, NULL, NULL}, + {"mode", (getter)buffered_mode_get, NULL, NULL}, {NULL} }; @@ -1842,14 +1841,14 @@ static PyGetSetDef BufferedWriter_getset[] = { PyTypeObject PyBufferedWriter_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.BufferedWriter", /*tp_name*/ - sizeof(BufferedObject), /*tp_basicsize*/ + sizeof(buffered), /*tp_basicsize*/ 0, /*tp_itemsize*/ - (destructor)BufferedObject_dealloc, /*tp_dealloc*/ + (destructor)buffered_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare */ - (reprfunc)Buffered_repr, /*tp_repr*/ + (reprfunc)buffered_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -1861,22 +1860,22 @@ PyTypeObject PyBufferedWriter_Type = { 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - BufferedWriter_doc, /* tp_doc */ - (traverseproc)Buffered_traverse, /* tp_traverse */ - (inquiry)Buffered_clear, /* tp_clear */ + bufferedwriter_doc, /* tp_doc */ + (traverseproc)buffered_traverse, /* tp_traverse */ + (inquiry)buffered_clear, /* tp_clear */ 0, /* tp_richcompare */ - offsetof(BufferedObject, weakreflist), /*tp_weaklistoffset*/ + offsetof(buffered, weakreflist), /*tp_weaklistoffset*/ 0, /* tp_iter */ 0, /* tp_iternext */ - BufferedWriter_methods, /* tp_methods */ - BufferedWriter_members, /* tp_members */ - BufferedWriter_getset, /* tp_getset */ + bufferedwriter_methods, /* tp_methods */ + bufferedwriter_members, /* tp_members */ + bufferedwriter_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(BufferedObject, dict), /* tp_dictoffset */ - (initproc)BufferedWriter_init, /* tp_init */ + offsetof(buffered, dict), /* tp_dictoffset */ + (initproc)bufferedwriter_init, /* tp_init */ 0, /* tp_alloc */ PyType_GenericNew, /* tp_new */ }; @@ -1887,7 +1886,7 @@ PyTypeObject PyBufferedWriter_Type = { * BufferedRWPair */ -PyDoc_STRVAR(BufferedRWPair_doc, +PyDoc_STRVAR(bufferedrwpair_doc, "A buffered reader and writer object together.\n" "\n" "A buffered reader object and buffered writer object put together to\n" @@ -1905,15 +1904,14 @@ PyDoc_STRVAR(BufferedRWPair_doc, typedef struct { PyObject_HEAD - BufferedObject *reader; - BufferedObject *writer; + buffered *reader; + buffered *writer; PyObject *dict; PyObject *weakreflist; -} BufferedRWPairObject; +} rwpair; static int -BufferedRWPair_init(BufferedRWPairObject *self, PyObject *args, - PyObject *kwds) +bufferedrwpair_init(rwpair *self, PyObject *args, PyObject *kwds) { PyObject *reader, *writer; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; @@ -1927,17 +1925,17 @@ BufferedRWPair_init(BufferedRWPairObject *self, PyObject *args, if (max_buffer_size != -234 && !complain_about_max_buffer_size()) return -1; - if (_PyIOBase_checkReadable(reader, Py_True) == NULL) + if (_PyIOBase_check_readable(reader, Py_True) == NULL) return -1; - if (_PyIOBase_checkWritable(writer, Py_True) == NULL) + if (_PyIOBase_check_writable(writer, Py_True) == NULL) return -1; - self->reader = (BufferedObject *) PyObject_CallFunction( + self->reader = (buffered *) PyObject_CallFunction( (PyObject *) &PyBufferedReader_Type, "On", reader, buffer_size); if (self->reader == NULL) return -1; - self->writer = (BufferedObject *) PyObject_CallFunction( + self->writer = (buffered *) PyObject_CallFunction( (PyObject *) &PyBufferedWriter_Type, "On", writer, buffer_size); if (self->writer == NULL) { Py_CLEAR(self->reader); @@ -1948,14 +1946,14 @@ BufferedRWPair_init(BufferedRWPairObject *self, PyObject *args, } static int -BufferedRWPair_traverse(BufferedRWPairObject *self, visitproc visit, void *arg) +bufferedrwpair_traverse(rwpair *self, visitproc visit, void *arg) { Py_VISIT(self->dict); return 0; } static int -BufferedRWPair_clear(BufferedRWPairObject *self) +bufferedrwpair_clear(rwpair *self) { Py_CLEAR(self->reader); Py_CLEAR(self->writer); @@ -1964,7 +1962,7 @@ BufferedRWPair_clear(BufferedRWPairObject *self) } static void -BufferedRWPair_dealloc(BufferedRWPairObject *self) +bufferedrwpair_dealloc(rwpair *self) { _PyObject_GC_UNTRACK(self); Py_CLEAR(self->reader); @@ -1974,7 +1972,7 @@ BufferedRWPair_dealloc(BufferedRWPairObject *self) } static PyObject * -_forward_call(BufferedObject *self, const char *name, PyObject *args) +_forward_call(buffered *self, const char *name, PyObject *args) { PyObject *func = PyObject_GetAttrString((PyObject *)self, name); PyObject *ret; @@ -1990,55 +1988,55 @@ _forward_call(BufferedObject *self, const char *name, PyObject *args) } static PyObject * -BufferedRWPair_read(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_read(rwpair *self, PyObject *args) { return _forward_call(self->reader, "read", args); } static PyObject * -BufferedRWPair_peek(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_peek(rwpair *self, PyObject *args) { return _forward_call(self->reader, "peek", args); } static PyObject * -BufferedRWPair_read1(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_read1(rwpair *self, PyObject *args) { return _forward_call(self->reader, "read1", args); } static PyObject * -BufferedRWPair_readinto(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_readinto(rwpair *self, PyObject *args) { return _forward_call(self->reader, "readinto", args); } static PyObject * -BufferedRWPair_write(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_write(rwpair *self, PyObject *args) { return _forward_call(self->writer, "write", args); } static PyObject * -BufferedRWPair_flush(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_flush(rwpair *self, PyObject *args) { return _forward_call(self->writer, "flush", args); } static PyObject * -BufferedRWPair_readable(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_readable(rwpair *self, PyObject *args) { return _forward_call(self->reader, "readable", args); } static PyObject * -BufferedRWPair_writable(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_writable(rwpair *self, PyObject *args) { return _forward_call(self->writer, "writable", args); } static PyObject * -BufferedRWPair_close(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_close(rwpair *self, PyObject *args) { PyObject *ret = _forward_call(self->writer, "close", args); if (ret == NULL) @@ -2049,7 +2047,7 @@ BufferedRWPair_close(BufferedRWPairObject *self, PyObject *args) } static PyObject * -BufferedRWPair_isatty(BufferedRWPairObject *self, PyObject *args) +bufferedrwpair_isatty(rwpair *self, PyObject *args) { PyObject *ret = _forward_call(self->writer, "isatty", args); @@ -2063,40 +2061,40 @@ BufferedRWPair_isatty(BufferedRWPairObject *self, PyObject *args) } static PyObject * -BufferedRWPair_closed_get(BufferedRWPairObject *self, void *context) +bufferedrwpair_closed_get(rwpair *self, void *context) { return PyObject_GetAttr((PyObject *) self->writer, _PyIO_str_closed); } -static PyMethodDef BufferedRWPair_methods[] = { - {"read", (PyCFunction)BufferedRWPair_read, METH_VARARGS}, - {"peek", (PyCFunction)BufferedRWPair_peek, METH_VARARGS}, - {"read1", (PyCFunction)BufferedRWPair_read1, METH_VARARGS}, - {"readinto", (PyCFunction)BufferedRWPair_readinto, METH_VARARGS}, +static PyMethodDef bufferedrwpair_methods[] = { + {"read", (PyCFunction)bufferedrwpair_read, METH_VARARGS}, + {"peek", (PyCFunction)bufferedrwpair_peek, METH_VARARGS}, + {"read1", (PyCFunction)bufferedrwpair_read1, METH_VARARGS}, + {"readinto", (PyCFunction)bufferedrwpair_readinto, METH_VARARGS}, - {"write", (PyCFunction)BufferedRWPair_write, METH_VARARGS}, - {"flush", (PyCFunction)BufferedRWPair_flush, METH_NOARGS}, + {"write", (PyCFunction)bufferedrwpair_write, METH_VARARGS}, + {"flush", (PyCFunction)bufferedrwpair_flush, METH_NOARGS}, - {"readable", (PyCFunction)BufferedRWPair_readable, METH_NOARGS}, - {"writable", (PyCFunction)BufferedRWPair_writable, METH_NOARGS}, + {"readable", (PyCFunction)bufferedrwpair_readable, METH_NOARGS}, + {"writable", (PyCFunction)bufferedrwpair_writable, METH_NOARGS}, - {"close", (PyCFunction)BufferedRWPair_close, METH_NOARGS}, - {"isatty", (PyCFunction)BufferedRWPair_isatty, METH_NOARGS}, + {"close", (PyCFunction)bufferedrwpair_close, METH_NOARGS}, + {"isatty", (PyCFunction)bufferedrwpair_isatty, METH_NOARGS}, {NULL, NULL} }; -static PyGetSetDef BufferedRWPair_getset[] = { - {"closed", (getter)BufferedRWPair_closed_get, NULL, NULL}, +static PyGetSetDef bufferedrwpair_getset[] = { + {"closed", (getter)bufferedrwpair_closed_get, NULL, NULL}, {NULL} }; PyTypeObject PyBufferedRWPair_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.BufferedRWPair", /*tp_name*/ - sizeof(BufferedRWPairObject), /*tp_basicsize*/ + sizeof(rwpair), /*tp_basicsize*/ 0, /*tp_itemsize*/ - (destructor)BufferedRWPair_dealloc, /*tp_dealloc*/ + (destructor)bufferedrwpair_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -2113,22 +2111,22 @@ PyTypeObject PyBufferedRWPair_Type = { 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - BufferedRWPair_doc, /* tp_doc */ - (traverseproc)BufferedRWPair_traverse, /* tp_traverse */ - (inquiry)BufferedRWPair_clear, /* tp_clear */ + bufferedrwpair_doc, /* tp_doc */ + (traverseproc)bufferedrwpair_traverse, /* tp_traverse */ + (inquiry)bufferedrwpair_clear, /* tp_clear */ 0, /* tp_richcompare */ - offsetof(BufferedRWPairObject, weakreflist), /*tp_weaklistoffset*/ + offsetof(rwpair, weakreflist), /*tp_weaklistoffset*/ 0, /* tp_iter */ 0, /* tp_iternext */ - BufferedRWPair_methods, /* tp_methods */ + bufferedrwpair_methods, /* tp_methods */ 0, /* tp_members */ - BufferedRWPair_getset, /* tp_getset */ + bufferedrwpair_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(BufferedRWPairObject, dict), /* tp_dictoffset */ - (initproc)BufferedRWPair_init, /* tp_init */ + offsetof(rwpair, dict), /* tp_dictoffset */ + (initproc)bufferedrwpair_init, /* tp_init */ 0, /* tp_alloc */ PyType_GenericNew, /* tp_new */ }; @@ -2139,7 +2137,7 @@ PyTypeObject PyBufferedRWPair_Type = { * BufferedRandom */ -PyDoc_STRVAR(BufferedRandom_doc, +PyDoc_STRVAR(bufferedrandom_doc, "A buffered interface to random access streams.\n" "\n" "The constructor creates a reader and writer for a seekable stream,\n" @@ -2148,7 +2146,7 @@ PyDoc_STRVAR(BufferedRandom_doc, ); static int -BufferedRandom_init(BufferedObject *self, PyObject *args, PyObject *kwds) +bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds) { char *kwlist[] = {"raw", "buffer_size", "max_buffer_size", NULL}; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; @@ -2166,11 +2164,11 @@ BufferedRandom_init(BufferedObject *self, PyObject *args, PyObject *kwds) if (max_buffer_size != -234 && !complain_about_max_buffer_size()) return -1; - if (_PyIOBase_checkSeekable(raw, Py_True) == NULL) + if (_PyIOBase_check_seekable(raw, Py_True) == NULL) return -1; - if (_PyIOBase_checkReadable(raw, Py_True) == NULL) + if (_PyIOBase_check_readable(raw, Py_True) == NULL) return -1; - if (_PyIOBase_checkWritable(raw, Py_True) == NULL) + if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; Py_CLEAR(self->raw); @@ -2180,10 +2178,10 @@ BufferedRandom_init(BufferedObject *self, PyObject *args, PyObject *kwds) self->readable = 1; self->writable = 1; - if (_Buffered_init(self) < 0) + if (_buffered_init(self) < 0) return -1; - _BufferedReader_reset_buf(self); - _BufferedWriter_reset_buf(self); + _bufferedreader_reset_buf(self); + _bufferedwriter_reset_buf(self); self->pos = 0; self->fast_closed_checks = (Py_TYPE(self) == &PyBufferedRandom_Type && @@ -2193,39 +2191,39 @@ BufferedRandom_init(BufferedObject *self, PyObject *args, PyObject *kwds) return 0; } -static PyMethodDef BufferedRandom_methods[] = { +static PyMethodDef bufferedrandom_methods[] = { /* BufferedIOMixin methods */ - {"close", (PyCFunction)BufferedIOMixin_close, METH_NOARGS}, - {"detach", (PyCFunction)BufferedIOMixin_detach, METH_NOARGS}, - {"seekable", (PyCFunction)BufferedIOMixin_seekable, METH_NOARGS}, - {"readable", (PyCFunction)BufferedIOMixin_readable, METH_NOARGS}, - {"writable", (PyCFunction)BufferedIOMixin_writable, METH_NOARGS}, - {"fileno", (PyCFunction)BufferedIOMixin_fileno, METH_NOARGS}, - {"isatty", (PyCFunction)BufferedIOMixin_isatty, METH_NOARGS}, - - {"flush", (PyCFunction)Buffered_flush, METH_NOARGS}, - - {"seek", (PyCFunction)Buffered_seek, METH_VARARGS}, - {"tell", (PyCFunction)Buffered_tell, METH_NOARGS}, - {"truncate", (PyCFunction)Buffered_truncate, METH_VARARGS}, - {"read", (PyCFunction)Buffered_read, METH_VARARGS}, - {"read1", (PyCFunction)Buffered_read1, METH_VARARGS}, - {"readinto", (PyCFunction)Buffered_readinto, METH_VARARGS}, - {"readline", (PyCFunction)Buffered_readline, METH_VARARGS}, - {"peek", (PyCFunction)Buffered_peek, METH_VARARGS}, - {"write", (PyCFunction)BufferedWriter_write, METH_VARARGS}, + {"close", (PyCFunction)buffered_close, METH_NOARGS}, + {"detach", (PyCFunction)buffered_detach, METH_NOARGS}, + {"seekable", (PyCFunction)buffered_seekable, METH_NOARGS}, + {"readable", (PyCFunction)buffered_readable, METH_NOARGS}, + {"writable", (PyCFunction)buffered_writable, METH_NOARGS}, + {"fileno", (PyCFunction)buffered_fileno, METH_NOARGS}, + {"isatty", (PyCFunction)buffered_isatty, METH_NOARGS}, + + {"flush", (PyCFunction)buffered_flush, METH_NOARGS}, + + {"seek", (PyCFunction)buffered_seek, METH_VARARGS}, + {"tell", (PyCFunction)buffered_tell, METH_NOARGS}, + {"truncate", (PyCFunction)buffered_truncate, METH_VARARGS}, + {"read", (PyCFunction)buffered_read, METH_VARARGS}, + {"read1", (PyCFunction)buffered_read1, METH_VARARGS}, + {"readinto", (PyCFunction)buffered_readinto, METH_VARARGS}, + {"readline", (PyCFunction)buffered_readline, METH_VARARGS}, + {"peek", (PyCFunction)buffered_peek, METH_VARARGS}, + {"write", (PyCFunction)bufferedwriter_write, METH_VARARGS}, {NULL, NULL} }; -static PyMemberDef BufferedRandom_members[] = { - {"raw", T_OBJECT, offsetof(BufferedObject, raw), 0}, +static PyMemberDef bufferedrandom_members[] = { + {"raw", T_OBJECT, offsetof(buffered, raw), 0}, {NULL} }; -static PyGetSetDef BufferedRandom_getset[] = { - {"closed", (getter)BufferedIOMixin_closed_get, NULL, NULL}, - {"name", (getter)BufferedIOMixin_name_get, NULL, NULL}, - {"mode", (getter)BufferedIOMixin_mode_get, NULL, NULL}, +static PyGetSetDef bufferedrandom_getset[] = { + {"closed", (getter)buffered_closed_get, NULL, NULL}, + {"name", (getter)buffered_name_get, NULL, NULL}, + {"mode", (getter)buffered_mode_get, NULL, NULL}, {NULL} }; @@ -2233,14 +2231,14 @@ static PyGetSetDef BufferedRandom_getset[] = { PyTypeObject PyBufferedRandom_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.BufferedRandom", /*tp_name*/ - sizeof(BufferedObject), /*tp_basicsize*/ + sizeof(buffered), /*tp_basicsize*/ 0, /*tp_itemsize*/ - (destructor)BufferedObject_dealloc, /*tp_dealloc*/ + (destructor)buffered_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare */ - (reprfunc)Buffered_repr, /*tp_repr*/ + (reprfunc)buffered_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -2252,22 +2250,22 @@ PyTypeObject PyBufferedRandom_Type = { 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - BufferedRandom_doc, /* tp_doc */ - (traverseproc)Buffered_traverse, /* tp_traverse */ - (inquiry)Buffered_clear, /* tp_clear */ + bufferedrandom_doc, /* tp_doc */ + (traverseproc)buffered_traverse, /* tp_traverse */ + (inquiry)buffered_clear, /* tp_clear */ 0, /* tp_richcompare */ - offsetof(BufferedObject, weakreflist), /*tp_weaklistoffset*/ + offsetof(buffered, weakreflist), /*tp_weaklistoffset*/ 0, /* tp_iter */ - (iternextfunc)Buffered_iternext, /* tp_iternext */ - BufferedRandom_methods, /* tp_methods */ - BufferedRandom_members, /* tp_members */ - BufferedRandom_getset, /* tp_getset */ + (iternextfunc)buffered_iternext, /* tp_iternext */ + bufferedrandom_methods, /* tp_methods */ + bufferedrandom_members, /* tp_members */ + bufferedrandom_getset, /* tp_getset */ 0, /* tp_base */ 0, /*tp_dict*/ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(BufferedObject, dict), /*tp_dictoffset*/ - (initproc)BufferedRandom_init, /* tp_init */ + offsetof(buffered, dict), /*tp_dictoffset*/ + (initproc)bufferedrandom_init, /* tp_init */ 0, /* tp_alloc */ PyType_GenericNew, /* tp_new */ }; diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index add61d5..7675846 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -10,7 +10,7 @@ typedef struct { size_t buf_size; PyObject *dict; PyObject *weakreflist; -} BytesIOObject; +} bytesio; #define CHECK_CLOSED(self) \ if ((self)->buf == NULL) { \ @@ -23,7 +23,7 @@ typedef struct { object. Returns the length between the current position to the next newline character. */ static Py_ssize_t -get_line(BytesIOObject *self, char **output) +get_line(bytesio *self, char **output) { char *n; const char *str_end; @@ -56,7 +56,7 @@ get_line(BytesIOObject *self, char **output) The caller should ensure that the 'size' argument is non-negative. Returns 0 on success, -1 otherwise. */ static int -resize_buffer(BytesIOObject *self, size_t size) +resize_buffer(bytesio *self, size_t size) { /* Here, unsigned types are used to avoid dealing with signed integer overflow, which is undefined in C. */ @@ -108,7 +108,7 @@ resize_buffer(BytesIOObject *self, size_t size) /* Internal routine for writing a string of bytes to the buffer of a BytesIO object. Returns the number of bytes wrote, or -1 on error. */ static Py_ssize_t -write_bytes(BytesIOObject *self, const char *bytes, Py_ssize_t len) +write_bytes(bytesio *self, const char *bytes, Py_ssize_t len) { assert(self->buf != NULL); assert(self->pos >= 0); @@ -146,7 +146,7 @@ write_bytes(BytesIOObject *self, const char *bytes, Py_ssize_t len) } static PyObject * -bytesio_get_closed(BytesIOObject *self) +bytesio_get_closed(bytesio *self) { if (self->buf == NULL) { Py_RETURN_TRUE; @@ -158,7 +158,7 @@ bytesio_get_closed(BytesIOObject *self) /* Generic getter for the writable, readable and seekable properties */ static PyObject * -return_true(BytesIOObject *self) +return_true(bytesio *self) { Py_RETURN_TRUE; } @@ -167,7 +167,7 @@ PyDoc_STRVAR(flush_doc, "flush() -> None. Does nothing."); static PyObject * -bytesio_flush(BytesIOObject *self) +bytesio_flush(bytesio *self) { Py_RETURN_NONE; } @@ -178,7 +178,7 @@ PyDoc_STRVAR(getval_doc, "Retrieve the entire contents of the BytesIO object."); static PyObject * -bytesio_getvalue(BytesIOObject *self) +bytesio_getvalue(bytesio *self) { CHECK_CLOSED(self); return PyBytes_FromStringAndSize(self->buf, self->string_size); @@ -191,7 +191,7 @@ PyDoc_STRVAR(isatty_doc, "to a tty-like device."); static PyObject * -bytesio_isatty(BytesIOObject *self) +bytesio_isatty(bytesio *self) { CHECK_CLOSED(self); Py_RETURN_FALSE; @@ -201,7 +201,7 @@ PyDoc_STRVAR(tell_doc, "tell() -> current file position, an integer\n"); static PyObject * -bytesio_tell(BytesIOObject *self) +bytesio_tell(bytesio *self) { CHECK_CLOSED(self); return PyLong_FromSsize_t(self->pos); @@ -214,7 +214,7 @@ PyDoc_STRVAR(read_doc, "Return an empty string at EOF."); static PyObject * -bytesio_read(BytesIOObject *self, PyObject *args) +bytesio_read(bytesio *self, PyObject *args) { Py_ssize_t size, n; char *output; @@ -263,7 +263,7 @@ PyDoc_STRVAR(read1_doc, "Return an empty string at EOF."); static PyObject * -bytesio_read1(BytesIOObject *self, PyObject *n) +bytesio_read1(bytesio *self, PyObject *n) { PyObject *arg, *res; @@ -283,7 +283,7 @@ PyDoc_STRVAR(readline_doc, "Return an empty string at EOF.\n"); static PyObject * -bytesio_readline(BytesIOObject *self, PyObject *args) +bytesio_readline(bytesio *self, PyObject *args) { Py_ssize_t size, n; char *output; @@ -328,7 +328,7 @@ PyDoc_STRVAR(readlines_doc, "total number of bytes in the lines returned.\n"); static PyObject * -bytesio_readlines(BytesIOObject *self, PyObject *args) +bytesio_readlines(bytesio *self, PyObject *args) { Py_ssize_t maxsize, size, n; PyObject *result, *line; @@ -387,7 +387,7 @@ PyDoc_STRVAR(readinto_doc, "is set not to block as has no data to read."); static PyObject * -bytesio_readinto(BytesIOObject *self, PyObject *buffer) +bytesio_readinto(bytesio *self, PyObject *buffer) { void *raw_buffer; Py_ssize_t len; @@ -415,7 +415,7 @@ PyDoc_STRVAR(truncate_doc, "Returns the new size. Imply an absolute seek to the position size."); static PyObject * -bytesio_truncate(BytesIOObject *self, PyObject *args) +bytesio_truncate(bytesio *self, PyObject *args) { Py_ssize_t size; PyObject *arg = Py_None; @@ -457,7 +457,7 @@ bytesio_truncate(BytesIOObject *self, PyObject *args) } static PyObject * -bytesio_iternext(BytesIOObject *self) +bytesio_iternext(bytesio *self) { char *next; Py_ssize_t n; @@ -482,7 +482,7 @@ PyDoc_STRVAR(seek_doc, "Returns the new absolute position."); static PyObject * -bytesio_seek(BytesIOObject *self, PyObject *args) +bytesio_seek(bytesio *self, PyObject *args) { Py_ssize_t pos; int mode = 0; @@ -536,7 +536,7 @@ PyDoc_STRVAR(write_doc, "Return the number of bytes written."); static PyObject * -bytesio_write(BytesIOObject *self, PyObject *obj) +bytesio_write(bytesio *self, PyObject *obj) { Py_ssize_t n = 0; Py_buffer buf; @@ -564,7 +564,7 @@ PyDoc_STRVAR(writelines_doc, "each string."); static PyObject * -bytesio_writelines(BytesIOObject *self, PyObject *v) +bytesio_writelines(bytesio *self, PyObject *v) { PyObject *it, *item; PyObject *ret; @@ -597,7 +597,7 @@ PyDoc_STRVAR(close_doc, "close() -> None. Disable all I/O operations."); static PyObject * -bytesio_close(BytesIOObject *self) +bytesio_close(bytesio *self) { if (self->buf != NULL) { PyMem_Free(self->buf); @@ -607,7 +607,7 @@ bytesio_close(BytesIOObject *self) } static void -bytesio_dealloc(BytesIOObject *self) +bytesio_dealloc(bytesio *self) { if (self->buf != NULL) { PyMem_Free(self->buf); @@ -620,10 +620,10 @@ bytesio_dealloc(BytesIOObject *self) static PyObject * bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - BytesIOObject *self; + bytesio *self; assert(type != NULL && type->tp_alloc != NULL); - self = (BytesIOObject *)type->tp_alloc(type, 0); + self = (bytesio *)type->tp_alloc(type, 0); if (self == NULL) return NULL; @@ -640,7 +640,7 @@ bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } static int -bytesio_init(BytesIOObject *self, PyObject *args, PyObject *kwds) +bytesio_init(bytesio *self, PyObject *args, PyObject *kwds) { PyObject *initvalue = NULL; @@ -664,7 +664,7 @@ bytesio_init(BytesIOObject *self, PyObject *args, PyObject *kwds) } static int -bytesio_traverse(BytesIOObject *self, visitproc visit, void *arg) +bytesio_traverse(bytesio *self, visitproc visit, void *arg) { Py_VISIT(self->dict); Py_VISIT(self->weakreflist); @@ -672,7 +672,7 @@ bytesio_traverse(BytesIOObject *self, visitproc visit, void *arg) } static int -bytesio_clear(BytesIOObject *self) +bytesio_clear(bytesio *self) { Py_CLEAR(self->dict); if (self->weakreflist != NULL) @@ -717,7 +717,7 @@ PyDoc_STRVAR(bytesio_doc, PyTypeObject PyBytesIO_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.BytesIO", /*tp_name*/ - sizeof(BytesIOObject), /*tp_basicsize*/ + sizeof(bytesio), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)bytesio_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ @@ -740,7 +740,7 @@ PyTypeObject PyBytesIO_Type = { (traverseproc)bytesio_traverse, /*tp_traverse*/ (inquiry)bytesio_clear, /*tp_clear*/ 0, /*tp_richcompare*/ - offsetof(BytesIOObject, weakreflist), /*tp_weaklistoffset*/ + offsetof(bytesio, weakreflist), /*tp_weaklistoffset*/ PyObject_SelfIter, /*tp_iter*/ (iternextfunc)bytesio_iternext, /*tp_iternext*/ bytesio_methods, /*tp_methods*/ @@ -750,7 +750,7 @@ PyTypeObject PyBytesIO_Type = { 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ - offsetof(BytesIOObject, dict), /*tp_dictoffset*/ + offsetof(bytesio, dict), /*tp_dictoffset*/ (initproc)bytesio_init, /*tp_init*/ 0, /*tp_alloc*/ bytesio_new, /*tp_new*/ diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index d063fbf..b21712c 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -51,7 +51,7 @@ typedef struct { int closefd : 1; PyObject *weakreflist; PyObject *dict; -} PyFileIOObject; +} fileio; PyTypeObject PyFileIO_Type; @@ -60,7 +60,7 @@ PyTypeObject PyFileIO_Type; int _PyFileIO_closed(PyObject *self) { - return ((PyFileIOObject *)self)->fd < 0; + return ((fileio *)self)->fd < 0; } static PyObject * @@ -70,7 +70,7 @@ static PyObject *portable_lseek(int fd, PyObject *posobj, int whence); /* Returns 0 on success, -1 with exception set on failure. */ static int -internal_close(PyFileIOObject *self) +internal_close(fileio *self) { int err = 0; int save_errno = 0; @@ -98,7 +98,7 @@ internal_close(PyFileIOObject *self) } static PyObject * -fileio_close(PyFileIOObject *self) +fileio_close(fileio *self) { if (!self->closefd) { self->fd = -1; @@ -115,11 +115,11 @@ fileio_close(PyFileIOObject *self) static PyObject * fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyFileIOObject *self; + fileio *self; assert(type != NULL && type->tp_alloc != NULL); - self = (PyFileIOObject *) type->tp_alloc(type, 0); + self = (fileio *) type->tp_alloc(type, 0); if (self != NULL) { self->fd = -1; self->readable = 0; @@ -137,7 +137,7 @@ fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) directories, so we need a check. */ static int -dircheck(PyFileIOObject* self, const char *name) +dircheck(fileio* self, const char *name) { #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) struct stat buf; @@ -181,7 +181,7 @@ check_fd(int fd) static int fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) { - PyFileIOObject *self = (PyFileIOObject *) oself; + fileio *self = (fileio *) oself; static char *kwlist[] = {"file", "mode", "closefd", NULL}; const char *name = NULL; PyObject *nameobj, *stringobj = NULL; @@ -380,21 +380,21 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) } static int -fileio_traverse(PyFileIOObject *self, visitproc visit, void *arg) +fileio_traverse(fileio *self, visitproc visit, void *arg) { Py_VISIT(self->dict); return 0; } static int -fileio_clear(PyFileIOObject *self) +fileio_clear(fileio *self) { Py_CLEAR(self->dict); return 0; } static void -fileio_dealloc(PyFileIOObject *self) +fileio_dealloc(fileio *self) { if (_PyIOBase_finalize((PyObject *) self) < 0) return; @@ -420,7 +420,7 @@ err_mode(char *action) } static PyObject * -fileio_fileno(PyFileIOObject *self) +fileio_fileno(fileio *self) { if (self->fd < 0) return err_closed(); @@ -428,7 +428,7 @@ fileio_fileno(PyFileIOObject *self) } static PyObject * -fileio_readable(PyFileIOObject *self) +fileio_readable(fileio *self) { if (self->fd < 0) return err_closed(); @@ -436,7 +436,7 @@ fileio_readable(PyFileIOObject *self) } static PyObject * -fileio_writable(PyFileIOObject *self) +fileio_writable(fileio *self) { if (self->fd < 0) return err_closed(); @@ -444,7 +444,7 @@ fileio_writable(PyFileIOObject *self) } static PyObject * -fileio_seekable(PyFileIOObject *self) +fileio_seekable(fileio *self) { if (self->fd < 0) return err_closed(); @@ -462,7 +462,7 @@ fileio_seekable(PyFileIOObject *self) } static PyObject * -fileio_readinto(PyFileIOObject *self, PyObject *args) +fileio_readinto(fileio *self, PyObject *args) { Py_buffer pbuf; Py_ssize_t n; @@ -494,7 +494,7 @@ fileio_readinto(PyFileIOObject *self, PyObject *args) } static size_t -new_buffersize(PyFileIOObject *self, size_t currentsize) +new_buffersize(fileio *self, size_t currentsize) { #ifdef HAVE_FSTAT off_t pos, end; @@ -524,7 +524,7 @@ new_buffersize(PyFileIOObject *self, size_t currentsize) } static PyObject * -fileio_readall(PyFileIOObject *self) +fileio_readall(fileio *self) { PyObject *result; Py_ssize_t total = 0; @@ -590,7 +590,7 @@ fileio_readall(PyFileIOObject *self) } static PyObject * -fileio_read(PyFileIOObject *self, PyObject *args) +fileio_read(fileio *self, PyObject *args) { char *ptr; Py_ssize_t n; @@ -641,7 +641,7 @@ fileio_read(PyFileIOObject *self, PyObject *args) } static PyObject * -fileio_write(PyFileIOObject *self, PyObject *args) +fileio_write(fileio *self, PyObject *args) { Py_buffer pbuf; Py_ssize_t n; @@ -734,7 +734,7 @@ portable_lseek(int fd, PyObject *posobj, int whence) } static PyObject * -fileio_seek(PyFileIOObject *self, PyObject *args) +fileio_seek(fileio *self, PyObject *args) { PyObject *posobj; int whence = 0; @@ -749,7 +749,7 @@ fileio_seek(PyFileIOObject *self, PyObject *args) } static PyObject * -fileio_tell(PyFileIOObject *self, PyObject *args) +fileio_tell(fileio *self, PyObject *args) { if (self->fd < 0) return err_closed(); @@ -759,7 +759,7 @@ fileio_tell(PyFileIOObject *self, PyObject *args) #ifdef HAVE_FTRUNCATE static PyObject * -fileio_truncate(PyFileIOObject *self, PyObject *args) +fileio_truncate(fileio *self, PyObject *args) { PyObject *posobj = NULL; Py_off_t pos; @@ -831,7 +831,7 @@ fileio_truncate(PyFileIOObject *self, PyObject *args) #endif static char * -mode_string(PyFileIOObject *self) +mode_string(fileio *self) { if (self->readable) { if (self->writable) @@ -844,7 +844,7 @@ mode_string(PyFileIOObject *self) } static PyObject * -fileio_repr(PyFileIOObject *self) +fileio_repr(fileio *self) { PyObject *nameobj, *res; @@ -869,7 +869,7 @@ fileio_repr(PyFileIOObject *self) } static PyObject * -fileio_isatty(PyFileIOObject *self) +fileio_isatty(fileio *self) { long res; @@ -980,19 +980,19 @@ static PyMethodDef fileio_methods[] = { /* 'closed' and 'mode' are attributes for backwards compatibility reasons. */ static PyObject * -get_closed(PyFileIOObject *self, void *closure) +get_closed(fileio *self, void *closure) { return PyBool_FromLong((long)(self->fd < 0)); } static PyObject * -get_closefd(PyFileIOObject *self, void *closure) +get_closefd(fileio *self, void *closure) { return PyBool_FromLong((long)(self->closefd)); } static PyObject * -get_mode(PyFileIOObject *self, void *closure) +get_mode(fileio *self, void *closure) { return PyUnicode_FromString(mode_string(self)); } @@ -1008,7 +1008,7 @@ static PyGetSetDef fileio_getsetlist[] = { PyTypeObject PyFileIO_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.FileIO", - sizeof(PyFileIOObject), + sizeof(fileio), 0, (destructor)fileio_dealloc, /* tp_dealloc */ 0, /* tp_print */ @@ -1031,7 +1031,7 @@ PyTypeObject PyFileIO_Type = { (traverseproc)fileio_traverse, /* tp_traverse */ (inquiry)fileio_clear, /* tp_clear */ 0, /* tp_richcompare */ - offsetof(PyFileIOObject, weakreflist), /* tp_weaklistoffset */ + offsetof(fileio, weakreflist), /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ fileio_methods, /* tp_methods */ @@ -1041,7 +1041,7 @@ PyTypeObject PyFileIO_Type = { 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(PyFileIOObject, dict), /* tp_dictoffset */ + offsetof(fileio, dict), /* tp_dictoffset */ fileio_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ fileio_new, /* tp_new */ diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index 5e018da..28042c6 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -22,9 +22,9 @@ typedef struct { PyObject *dict; PyObject *weakreflist; -} IOBaseObject; +} iobase; -PyDoc_STRVAR(IOBase_doc, +PyDoc_STRVAR(iobase_doc, "The abstract base class for all I/O classes, acting on streams of\n" "bytes. There is no public constructor.\n" "\n" @@ -63,7 +63,7 @@ PyDoc_STRVAR(IOBase_doc, /* Internal methods */ static PyObject * -IOBase_unsupported(const char *message) +iobase_unsupported(const char *message) { PyErr_SetString(IO_STATE->unsupported_operation, message); return NULL; @@ -71,7 +71,7 @@ IOBase_unsupported(const char *message) /* Positionning */ -PyDoc_STRVAR(IOBase_seek_doc, +PyDoc_STRVAR(iobase_seek_doc, "Change stream position.\n" "\n" "Change the stream position to byte offset offset. offset is\n" @@ -85,41 +85,41 @@ PyDoc_STRVAR(IOBase_seek_doc, "Return the new absolute position."); static PyObject * -IOBase_seek(PyObject *self, PyObject *args) +iobase_seek(PyObject *self, PyObject *args) { - return IOBase_unsupported("seek"); + return iobase_unsupported("seek"); } -PyDoc_STRVAR(IOBase_tell_doc, +PyDoc_STRVAR(iobase_tell_doc, "Return current stream position."); static PyObject * -IOBase_tell(PyObject *self, PyObject *args) +iobase_tell(PyObject *self, PyObject *args) { return PyObject_CallMethod(self, "seek", "ii", 0, 1); } -PyDoc_STRVAR(IOBase_truncate_doc, +PyDoc_STRVAR(iobase_truncate_doc, "Truncate file to size bytes.\n" "\n" "Size defaults to the current IO position as reported by tell(). Return\n" "the new size."); static PyObject * -IOBase_truncate(PyObject *self, PyObject *args) +iobase_truncate(PyObject *self, PyObject *args) { - return IOBase_unsupported("truncate"); + return iobase_unsupported("truncate"); } /* Flush and close methods */ -PyDoc_STRVAR(IOBase_flush_doc, +PyDoc_STRVAR(iobase_flush_doc, "Flush write buffers, if applicable.\n" "\n" "This is not implemented for read-only and non-blocking streams.\n"); static PyObject * -IOBase_flush(PyObject *self, PyObject *args) +iobase_flush(PyObject *self, PyObject *args) { /* XXX Should this return the number of bytes written??? */ if (IS_CLOSED(self)) { @@ -129,13 +129,13 @@ IOBase_flush(PyObject *self, PyObject *args) Py_RETURN_NONE; } -PyDoc_STRVAR(IOBase_close_doc, +PyDoc_STRVAR(iobase_close_doc, "Flush and close the IO object.\n" "\n" "This method has no effect if the file is already closed.\n"); static int -IOBase_closed(PyObject *self) +iobase_closed(PyObject *self) { PyObject *res; int closed; @@ -150,15 +150,15 @@ IOBase_closed(PyObject *self) } static PyObject * -IOBase_closed_get(PyObject *self, void *context) +iobase_closed_get(PyObject *self, void *context) { return PyBool_FromLong(IS_CLOSED(self)); } PyObject * -_PyIOBase_checkClosed(PyObject *self, PyObject *args) +_PyIOBase_check_closed(PyObject *self, PyObject *args) { - if (IOBase_closed(self)) { + if (iobase_closed(self)) { PyErr_SetString(PyExc_ValueError, "I/O operation on closed file."); return NULL; } @@ -173,7 +173,7 @@ _PyIOBase_checkClosed(PyObject *self, PyObject *args) whatever behaviour a non-trivial derived class will implement. */ static PyObject * -IOBase_close(PyObject *self, PyObject *args) +iobase_close(PyObject *self, PyObject *args) { PyObject *res; @@ -260,14 +260,14 @@ _PyIOBase_finalize(PyObject *self) } static int -IOBase_traverse(IOBaseObject *self, visitproc visit, void *arg) +iobase_traverse(iobase *self, visitproc visit, void *arg) { Py_VISIT(self->dict); return 0; } static int -IOBase_clear(IOBaseObject *self) +iobase_clear(iobase *self) { if (_PyIOBase_finalize((PyObject *) self) < 0) return -1; @@ -278,7 +278,7 @@ IOBase_clear(IOBaseObject *self) /* Destructor */ static void -IOBase_dealloc(IOBaseObject *self) +iobase_dealloc(iobase *self) { /* NOTE: since IOBaseObject has its own dict, Python-defined attributes are still available here for close() to use. @@ -301,20 +301,20 @@ IOBase_dealloc(IOBaseObject *self) /* Inquiry methods */ -PyDoc_STRVAR(IOBase_seekable_doc, +PyDoc_STRVAR(iobase_seekable_doc, "Return whether object supports random access.\n" "\n" "If False, seek(), tell() and truncate() will raise IOError.\n" "This method may need to do a test seek()."); static PyObject * -IOBase_seekable(PyObject *self, PyObject *args) +iobase_seekable(PyObject *self, PyObject *args) { Py_RETURN_FALSE; } PyObject * -_PyIOBase_checkSeekable(PyObject *self, PyObject *args) +_PyIOBase_check_seekable(PyObject *self, PyObject *args) { PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_seekable, NULL); if (res == NULL) @@ -330,20 +330,20 @@ _PyIOBase_checkSeekable(PyObject *self, PyObject *args) return res; } -PyDoc_STRVAR(IOBase_readable_doc, +PyDoc_STRVAR(iobase_readable_doc, "Return whether object was opened for reading.\n" "\n" "If False, read() will raise IOError."); static PyObject * -IOBase_readable(PyObject *self, PyObject *args) +iobase_readable(PyObject *self, PyObject *args) { Py_RETURN_FALSE; } /* May be called with any object */ PyObject * -_PyIOBase_checkReadable(PyObject *self, PyObject *args) +_PyIOBase_check_readable(PyObject *self, PyObject *args) { PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_readable, NULL); if (res == NULL) @@ -359,20 +359,20 @@ _PyIOBase_checkReadable(PyObject *self, PyObject *args) return res; } -PyDoc_STRVAR(IOBase_writable_doc, +PyDoc_STRVAR(iobase_writable_doc, "Return whether object was opened for writing.\n" "\n" "If False, read() will raise IOError."); static PyObject * -IOBase_writable(PyObject *self, PyObject *args) +iobase_writable(PyObject *self, PyObject *args) { Py_RETURN_FALSE; } /* May be called with any object */ PyObject * -_PyIOBase_checkWritable(PyObject *self, PyObject *args) +_PyIOBase_check_writable(PyObject *self, PyObject *args) { PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_writable, NULL); if (res == NULL) @@ -391,9 +391,9 @@ _PyIOBase_checkWritable(PyObject *self, PyObject *args) /* Context manager */ static PyObject * -IOBase_enter(PyObject *self, PyObject *args) +iobase_enter(PyObject *self, PyObject *args) { - if (_PyIOBase_checkClosed(self, Py_True) == NULL) + if (_PyIOBase_check_closed(self, Py_True) == NULL) return NULL; Py_INCREF(self); @@ -401,7 +401,7 @@ IOBase_enter(PyObject *self, PyObject *args) } static PyObject * -IOBase_exit(PyObject *self, PyObject *args) +iobase_exit(PyObject *self, PyObject *args) { return PyObject_CallMethodObjArgs(self, _PyIO_str_close, NULL); } @@ -410,33 +410,33 @@ IOBase_exit(PyObject *self, PyObject *args) /* XXX Should these be present even if unimplemented? */ -PyDoc_STRVAR(IOBase_fileno_doc, +PyDoc_STRVAR(iobase_fileno_doc, "Returns underlying file descriptor if one exists.\n" "\n" "An IOError is raised if the IO object does not use a file descriptor.\n"); static PyObject * -IOBase_fileno(PyObject *self, PyObject *args) +iobase_fileno(PyObject *self, PyObject *args) { - return IOBase_unsupported("fileno"); + return iobase_unsupported("fileno"); } -PyDoc_STRVAR(IOBase_isatty_doc, +PyDoc_STRVAR(iobase_isatty_doc, "Return whether this is an 'interactive' stream.\n" "\n" "Return False if it can't be determined.\n"); static PyObject * -IOBase_isatty(PyObject *self, PyObject *args) +iobase_isatty(PyObject *self, PyObject *args) { - if (_PyIOBase_checkClosed(self, Py_True) == NULL) + if (_PyIOBase_check_closed(self, Py_True) == NULL) return NULL; Py_RETURN_FALSE; } /* Readline(s) and writelines */ -PyDoc_STRVAR(IOBase_readline_doc, +PyDoc_STRVAR(iobase_readline_doc, "Read and return a line from the stream.\n" "\n" "If limit is specified, at most limit bytes will be read.\n" @@ -446,7 +446,7 @@ PyDoc_STRVAR(IOBase_readline_doc, "terminator(s) recognized.\n"); static PyObject * -IOBase_readline(PyObject *self, PyObject *args) +iobase_readline(PyObject *self, PyObject *args) { /* For backwards compatibility, a (slowish) readline(). */ @@ -541,9 +541,9 @@ IOBase_readline(PyObject *self, PyObject *args) } static PyObject * -IOBase_iter(PyObject *self) +iobase_iter(PyObject *self) { - if (_PyIOBase_checkClosed(self, Py_True) == NULL) + if (_PyIOBase_check_closed(self, Py_True) == NULL) return NULL; Py_INCREF(self); @@ -551,7 +551,7 @@ IOBase_iter(PyObject *self) } static PyObject * -IOBase_iternext(PyObject *self) +iobase_iternext(PyObject *self) { PyObject *line = PyObject_CallMethodObjArgs(self, _PyIO_str_readline, NULL); @@ -566,7 +566,7 @@ IOBase_iternext(PyObject *self) return line; } -PyDoc_STRVAR(IOBase_readlines_doc, +PyDoc_STRVAR(iobase_readlines_doc, "Return a list of lines from the stream.\n" "\n" "hint can be specified to control the number of lines read: no more\n" @@ -574,7 +574,7 @@ PyDoc_STRVAR(IOBase_readlines_doc, "lines so far exceeds hint."); static PyObject * -IOBase_readlines(PyObject *self, PyObject *args) +iobase_readlines(PyObject *self, PyObject *args) { Py_ssize_t hint = -1, length = 0; PyObject *hintobj = Py_None, *result; @@ -631,7 +631,7 @@ IOBase_readlines(PyObject *self, PyObject *args) } static PyObject * -IOBase_writelines(PyObject *self, PyObject *args) +iobase_writelines(PyObject *self, PyObject *args) { PyObject *lines, *iter, *res; @@ -639,7 +639,7 @@ IOBase_writelines(PyObject *self, PyObject *args) return NULL; } - if (_PyIOBase_checkClosed(self, Py_True) == NULL) + if (_PyIOBase_check_closed(self, Py_True) == NULL) return NULL; iter = PyObject_GetIter(lines); @@ -669,37 +669,37 @@ IOBase_writelines(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyMethodDef IOBase_methods[] = { - {"seek", IOBase_seek, METH_VARARGS, IOBase_seek_doc}, - {"tell", IOBase_tell, METH_NOARGS, IOBase_tell_doc}, - {"truncate", IOBase_truncate, METH_VARARGS, IOBase_truncate_doc}, - {"flush", IOBase_flush, METH_NOARGS, IOBase_flush_doc}, - {"close", IOBase_close, METH_NOARGS, IOBase_close_doc}, +static PyMethodDef iobase_methods[] = { + {"seek", iobase_seek, METH_VARARGS, iobase_seek_doc}, + {"tell", iobase_tell, METH_NOARGS, iobase_tell_doc}, + {"truncate", iobase_truncate, METH_VARARGS, iobase_truncate_doc}, + {"flush", iobase_flush, METH_NOARGS, iobase_flush_doc}, + {"close", iobase_close, METH_NOARGS, iobase_close_doc}, - {"seekable", IOBase_seekable, METH_NOARGS, IOBase_seekable_doc}, - {"readable", IOBase_readable, METH_NOARGS, IOBase_readable_doc}, - {"writable", IOBase_writable, METH_NOARGS, IOBase_writable_doc}, + {"seekable", iobase_seekable, METH_NOARGS, iobase_seekable_doc}, + {"readable", iobase_readable, METH_NOARGS, iobase_readable_doc}, + {"writable", iobase_writable, METH_NOARGS, iobase_writable_doc}, - {"_checkClosed", _PyIOBase_checkClosed, METH_NOARGS}, - {"_checkSeekable", _PyIOBase_checkSeekable, METH_NOARGS}, - {"_checkReadable", _PyIOBase_checkReadable, METH_NOARGS}, - {"_checkWritable", _PyIOBase_checkWritable, METH_NOARGS}, + {"_checkClosed", _PyIOBase_check_closed, METH_NOARGS}, + {"_checkSeekable", _PyIOBase_check_seekable, METH_NOARGS}, + {"_checkReadable", _PyIOBase_check_readable, METH_NOARGS}, + {"_checkWritable", _PyIOBase_check_writable, METH_NOARGS}, - {"fileno", IOBase_fileno, METH_NOARGS, IOBase_fileno_doc}, - {"isatty", IOBase_isatty, METH_NOARGS, IOBase_isatty_doc}, + {"fileno", iobase_fileno, METH_NOARGS, iobase_fileno_doc}, + {"isatty", iobase_isatty, METH_NOARGS, iobase_isatty_doc}, - {"__enter__", IOBase_enter, METH_NOARGS}, - {"__exit__", IOBase_exit, METH_VARARGS}, + {"__enter__", iobase_enter, METH_NOARGS}, + {"__exit__", iobase_exit, METH_VARARGS}, - {"readline", IOBase_readline, METH_VARARGS, IOBase_readline_doc}, - {"readlines", IOBase_readlines, METH_VARARGS, IOBase_readlines_doc}, - {"writelines", IOBase_writelines, METH_VARARGS}, + {"readline", iobase_readline, METH_VARARGS, iobase_readline_doc}, + {"readlines", iobase_readlines, METH_VARARGS, iobase_readlines_doc}, + {"writelines", iobase_writelines, METH_VARARGS}, {NULL, NULL} }; -static PyGetSetDef IOBase_getset[] = { - {"closed", (getter)IOBase_closed_get, NULL, NULL}, +static PyGetSetDef iobase_getset[] = { + {"closed", (getter)iobase_closed_get, NULL, NULL}, {NULL} }; @@ -707,9 +707,9 @@ static PyGetSetDef IOBase_getset[] = { PyTypeObject PyIOBase_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io._IOBase", /*tp_name*/ - sizeof(IOBaseObject), /*tp_basicsize*/ + sizeof(iobase), /*tp_basicsize*/ 0, /*tp_itemsize*/ - (destructor)IOBase_dealloc, /*tp_dealloc*/ + (destructor)iobase_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -726,21 +726,21 @@ PyTypeObject PyIOBase_Type = { 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - IOBase_doc, /* tp_doc */ - (traverseproc)IOBase_traverse, /* tp_traverse */ - (inquiry)IOBase_clear, /* tp_clear */ + iobase_doc, /* tp_doc */ + (traverseproc)iobase_traverse, /* tp_traverse */ + (inquiry)iobase_clear, /* tp_clear */ 0, /* tp_richcompare */ - offsetof(IOBaseObject, weakreflist), /* tp_weaklistoffset */ - IOBase_iter, /* tp_iter */ - IOBase_iternext, /* tp_iternext */ - IOBase_methods, /* tp_methods */ + offsetof(iobase, weakreflist), /* tp_weaklistoffset */ + iobase_iter, /* tp_iter */ + iobase_iternext, /* tp_iternext */ + iobase_methods, /* tp_methods */ 0, /* tp_members */ - IOBase_getset, /* tp_getset */ + iobase_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(IOBaseObject, dict), /* tp_dictoffset */ + offsetof(iobase, dict), /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ PyType_GenericNew, /* tp_new */ @@ -750,7 +750,7 @@ PyTypeObject PyIOBase_Type = { /* * RawIOBase class, Inherits from IOBase. */ -PyDoc_STRVAR(RawIOBase_doc, +PyDoc_STRVAR(rawiobase_doc, "Base class for raw binary I/O."); /* @@ -766,7 +766,7 @@ PyDoc_STRVAR(RawIOBase_doc, */ static PyObject * -RawIOBase_read(PyObject *self, PyObject *args) +rawiobase_read(PyObject *self, PyObject *args) { Py_ssize_t n = -1; PyObject *b, *res; @@ -803,11 +803,11 @@ RawIOBase_read(PyObject *self, PyObject *args) } -PyDoc_STRVAR(RawIOBase_readall_doc, +PyDoc_STRVAR(rawiobase_readall_doc, "Read until EOF, using multiple read() call."); static PyObject * -RawIOBase_readall(PyObject *self, PyObject *args) +rawiobase_readall(PyObject *self, PyObject *args) { int r; PyObject *chunks = PyList_New(0); @@ -846,9 +846,9 @@ RawIOBase_readall(PyObject *self, PyObject *args) return result; } -static PyMethodDef RawIOBase_methods[] = { - {"read", RawIOBase_read, METH_VARARGS}, - {"readall", RawIOBase_readall, METH_NOARGS, RawIOBase_readall_doc}, +static PyMethodDef rawiobase_methods[] = { + {"read", rawiobase_read, METH_VARARGS}, + {"readall", rawiobase_readall, METH_NOARGS, rawiobase_readall_doc}, {NULL, NULL} }; @@ -873,14 +873,14 @@ PyTypeObject PyRawIOBase_Type = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - RawIOBase_doc, /* tp_doc */ + rawiobase_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - RawIOBase_methods, /* tp_methods */ + rawiobase_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ &PyIOBase_Type, /* tp_base */ diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c index a0d8a51..57dacf9 100644 --- a/Modules/_io/stringio.c +++ b/Modules/_io/stringio.c @@ -24,7 +24,7 @@ typedef struct { PyObject *dict; PyObject *weakreflist; -} StringIOObject; +} stringio; #define CHECK_INITIALIZED(self) \ if (self->ok <= 0) { \ @@ -51,7 +51,7 @@ PyDoc_STRVAR(stringio_doc, buffer of StringIO objects. The caller should ensure that the 'size' argument is non-negative. Returns 0 on success, -1 otherwise. */ static int -resize_buffer(StringIOObject *self, size_t size) +resize_buffer(stringio *self, size_t size) { /* Here, unsigned types are used to avoid dealing with signed integer overflow, which is undefined in C. */ @@ -106,7 +106,7 @@ resize_buffer(StringIOObject *self, size_t size) /* Internal routine for writing a whole PyUnicode object to the buffer of a StringIO object. Returns 0 on success, or -1 on error. */ static Py_ssize_t -write_str(StringIOObject *self, PyObject *obj) +write_str(stringio *self, PyObject *obj) { Py_UNICODE *str; Py_ssize_t len; @@ -186,7 +186,7 @@ PyDoc_STRVAR(stringio_getvalue_doc, "Retrieve the entire contents of the object."); static PyObject * -stringio_getvalue(StringIOObject *self) +stringio_getvalue(stringio *self) { CHECK_INITIALIZED(self); CHECK_CLOSED(self); @@ -197,7 +197,7 @@ PyDoc_STRVAR(stringio_tell_doc, "Tell the current file position."); static PyObject * -stringio_tell(StringIOObject *self) +stringio_tell(stringio *self) { CHECK_INITIALIZED(self); CHECK_CLOSED(self); @@ -211,7 +211,7 @@ PyDoc_STRVAR(stringio_read_doc, "is reached. Return an empty string at EOF.\n"); static PyObject * -stringio_read(StringIOObject *self, PyObject *args) +stringio_read(stringio *self, PyObject *args) { Py_ssize_t size, n; Py_UNICODE *output; @@ -252,7 +252,7 @@ stringio_read(StringIOObject *self, PyObject *args) /* Internal helper, used by stringio_readline and stringio_iternext */ static PyObject * -_stringio_readline(StringIOObject *self, Py_ssize_t limit) +_stringio_readline(stringio *self, Py_ssize_t limit) { Py_UNICODE *start, *end, old_char; Py_ssize_t len, consumed; @@ -286,7 +286,7 @@ PyDoc_STRVAR(stringio_readline_doc, "Returns an empty string if EOF is hit immediately.\n"); static PyObject * -stringio_readline(StringIOObject *self, PyObject *args) +stringio_readline(stringio *self, PyObject *args) { PyObject *arg = Py_None; Py_ssize_t limit = -1; @@ -310,7 +310,7 @@ stringio_readline(StringIOObject *self, PyObject *args) } static PyObject * -stringio_iternext(StringIOObject *self) +stringio_iternext(stringio *self) { PyObject *line; @@ -354,7 +354,7 @@ PyDoc_STRVAR(stringio_truncate_doc, "Returns the new absolute position.\n"); static PyObject * -stringio_truncate(StringIOObject *self, PyObject *args) +stringio_truncate(stringio *self, PyObject *args) { Py_ssize_t size; PyObject *arg = Py_None; @@ -405,7 +405,7 @@ PyDoc_STRVAR(stringio_seek_doc, "Returns the new absolute position.\n"); static PyObject * -stringio_seek(StringIOObject *self, PyObject *args) +stringio_seek(stringio *self, PyObject *args) { Py_ssize_t pos; int mode = 0; @@ -453,7 +453,7 @@ PyDoc_STRVAR(stringio_write_doc, "the length of the string.\n"); static PyObject * -stringio_write(StringIOObject *self, PyObject *obj) +stringio_write(stringio *self, PyObject *obj) { Py_ssize_t size; @@ -479,7 +479,7 @@ PyDoc_STRVAR(stringio_close_doc, "This method has no effect if the file is already closed.\n"); static PyObject * -stringio_close(StringIOObject *self) +stringio_close(stringio *self) { self->closed = 1; /* Free up some memory */ @@ -492,21 +492,21 @@ stringio_close(StringIOObject *self) } static int -stringio_traverse(StringIOObject *self, visitproc visit, void *arg) +stringio_traverse(stringio *self, visitproc visit, void *arg) { Py_VISIT(self->dict); return 0; } static int -stringio_clear(StringIOObject *self) +stringio_clear(stringio *self) { Py_CLEAR(self->dict); return 0; } static void -stringio_dealloc(StringIOObject *self) +stringio_dealloc(stringio *self) { _PyObject_GC_UNTRACK(self); Py_CLEAR(self->readnl); @@ -522,10 +522,10 @@ stringio_dealloc(StringIOObject *self) static PyObject * stringio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - StringIOObject *self; + stringio *self; assert(type != NULL && type->tp_alloc != NULL); - self = (StringIOObject *)type->tp_alloc(type, 0); + self = (stringio *)type->tp_alloc(type, 0); if (self == NULL) return NULL; @@ -542,7 +542,7 @@ stringio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } static int -stringio_init(StringIOObject *self, PyObject *args, PyObject *kwds) +stringio_init(stringio *self, PyObject *args, PyObject *kwds) { char *kwlist[] = {"initial_value", "newline", NULL}; PyObject *value = NULL; @@ -625,28 +625,28 @@ stringio_init(StringIOObject *self, PyObject *args, PyObject *kwds) /* Properties and pseudo-properties */ static PyObject * -stringio_seekable(StringIOObject *self, PyObject *args) +stringio_seekable(stringio *self, PyObject *args) { CHECK_INITIALIZED(self); Py_RETURN_TRUE; } static PyObject * -stringio_readable(StringIOObject *self, PyObject *args) +stringio_readable(stringio *self, PyObject *args) { CHECK_INITIALIZED(self); Py_RETURN_TRUE; } static PyObject * -stringio_writable(StringIOObject *self, PyObject *args) +stringio_writable(stringio *self, PyObject *args) { CHECK_INITIALIZED(self); Py_RETURN_TRUE; } static PyObject * -stringio_buffer(StringIOObject *self, void *context) +stringio_buffer(stringio *self, void *context) { PyErr_SetString(IO_STATE->unsupported_operation, "buffer attribute is unsupported on type StringIO"); @@ -654,14 +654,14 @@ stringio_buffer(StringIOObject *self, void *context) } static PyObject * -stringio_closed(StringIOObject *self, void *context) +stringio_closed(stringio *self, void *context) { CHECK_INITIALIZED(self); return PyBool_FromLong(self->closed); } static PyObject * -stringio_line_buffering(StringIOObject *self, void *context) +stringio_line_buffering(stringio *self, void *context) { CHECK_INITIALIZED(self); CHECK_CLOSED(self); @@ -669,7 +669,7 @@ stringio_line_buffering(StringIOObject *self, void *context) } static PyObject * -stringio_newlines(StringIOObject *self, void *context) +stringio_newlines(stringio *self, void *context) { CHECK_INITIALIZED(self); CHECK_CLOSED(self); @@ -711,7 +711,7 @@ static PyGetSetDef stringio_getset[] = { PyTypeObject PyStringIO_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.StringIO", /*tp_name*/ - sizeof(StringIOObject), /*tp_basicsize*/ + sizeof(stringio), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)stringio_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ @@ -734,7 +734,7 @@ PyTypeObject PyStringIO_Type = { (traverseproc)stringio_traverse, /*tp_traverse*/ (inquiry)stringio_clear, /*tp_clear*/ 0, /*tp_richcompare*/ - offsetof(StringIOObject, weakreflist), /*tp_weaklistoffset*/ + offsetof(stringio, weakreflist), /*tp_weaklistoffset*/ 0, /*tp_iter*/ (iternextfunc)stringio_iternext, /*tp_iternext*/ stringio_methods, /*tp_methods*/ @@ -744,7 +744,7 @@ PyTypeObject PyStringIO_Type = { 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ - offsetof(StringIOObject, dict), /*tp_dictoffset*/ + offsetof(stringio, dict), /*tp_dictoffset*/ (initproc)stringio_init, /*tp_init*/ 0, /*tp_alloc*/ stringio_new, /*tp_new*/ diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 220af8d..0f5a73d 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -13,7 +13,7 @@ /* TextIOBase */ -PyDoc_STRVAR(TextIOBase_doc, +PyDoc_STRVAR(textiobase_doc, "Base class for text I/O.\n" "\n" "This class provides a character and line based interface to stream\n" @@ -28,7 +28,7 @@ _unsupported(const char *message) return NULL; } -PyDoc_STRVAR(TextIOBase_detach_doc, +PyDoc_STRVAR(textiobase_detach_doc, "Separate the underlying buffer from the TextIOBase and return it.\n" "\n" "After the underlying buffer has been detached, the TextIO is in an\n" @@ -36,12 +36,12 @@ PyDoc_STRVAR(TextIOBase_detach_doc, ); static PyObject * -TextIOBase_detach(PyObject *self) +textiobase_detach(PyObject *self) { return _unsupported("detach"); } -PyDoc_STRVAR(TextIOBase_read_doc, +PyDoc_STRVAR(textiobase_read_doc, "Read at most n characters from stream.\n" "\n" "Read from underlying buffer until we have n characters or we hit EOF.\n" @@ -49,48 +49,48 @@ PyDoc_STRVAR(TextIOBase_read_doc, ); static PyObject * -TextIOBase_read(PyObject *self, PyObject *args) +textiobase_read(PyObject *self, PyObject *args) { return _unsupported("read"); } -PyDoc_STRVAR(TextIOBase_readline_doc, +PyDoc_STRVAR(textiobase_readline_doc, "Read until newline or EOF.\n" "\n" "Returns an empty string if EOF is hit immediately.\n" ); static PyObject * -TextIOBase_readline(PyObject *self, PyObject *args) +textiobase_readline(PyObject *self, PyObject *args) { return _unsupported("readline"); } -PyDoc_STRVAR(TextIOBase_write_doc, +PyDoc_STRVAR(textiobase_write_doc, "Write string to stream.\n" "Returns the number of characters written (which is always equal to\n" "the length of the string).\n" ); static PyObject * -TextIOBase_write(PyObject *self, PyObject *args) +textiobase_write(PyObject *self, PyObject *args) { return _unsupported("write"); } -PyDoc_STRVAR(TextIOBase_encoding_doc, +PyDoc_STRVAR(textiobase_encoding_doc, "Encoding of the text stream.\n" "\n" "Subclasses should override.\n" ); static PyObject * -TextIOBase_encoding_get(PyObject *self, void *context) +textiobase_encoding_get(PyObject *self, void *context) { Py_RETURN_NONE; } -PyDoc_STRVAR(TextIOBase_newlines_doc, +PyDoc_STRVAR(textiobase_newlines_doc, "Line endings translated so far.\n" "\n" "Only line endings translated during reading are considered.\n" @@ -99,36 +99,36 @@ PyDoc_STRVAR(TextIOBase_newlines_doc, ); static PyObject * -TextIOBase_newlines_get(PyObject *self, void *context) +textiobase_newlines_get(PyObject *self, void *context) { Py_RETURN_NONE; } -PyDoc_STRVAR(TextIOBase_errors_doc, +PyDoc_STRVAR(textiobase_errors_doc, "The error setting of the decoder or encoder.\n" "\n" "Subclasses should override.\n" ); static PyObject * -TextIOBase_errors_get(PyObject *self, void *context) +textiobase_errors_get(PyObject *self, void *context) { Py_RETURN_NONE; } -static PyMethodDef TextIOBase_methods[] = { - {"detach", (PyCFunction)TextIOBase_detach, METH_NOARGS, TextIOBase_detach_doc}, - {"read", TextIOBase_read, METH_VARARGS, TextIOBase_read_doc}, - {"readline", TextIOBase_readline, METH_VARARGS, TextIOBase_readline_doc}, - {"write", TextIOBase_write, METH_VARARGS, TextIOBase_write_doc}, +static PyMethodDef textiobase_methods[] = { + {"detach", (PyCFunction)textiobase_detach, METH_NOARGS, textiobase_detach_doc}, + {"read", textiobase_read, METH_VARARGS, textiobase_read_doc}, + {"readline", textiobase_readline, METH_VARARGS, textiobase_readline_doc}, + {"write", textiobase_write, METH_VARARGS, textiobase_write_doc}, {NULL, NULL} }; -static PyGetSetDef TextIOBase_getset[] = { - {"encoding", (getter)TextIOBase_encoding_get, NULL, TextIOBase_encoding_doc}, - {"newlines", (getter)TextIOBase_newlines_get, NULL, TextIOBase_newlines_doc}, - {"errors", (getter)TextIOBase_errors_get, NULL, TextIOBase_errors_doc}, +static PyGetSetDef textiobase_getset[] = { + {"encoding", (getter)textiobase_encoding_get, NULL, textiobase_encoding_doc}, + {"newlines", (getter)textiobase_newlines_get, NULL, textiobase_newlines_doc}, + {"errors", (getter)textiobase_errors_get, NULL, textiobase_errors_doc}, {NULL} }; @@ -153,16 +153,16 @@ PyTypeObject PyTextIOBase_Type = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - TextIOBase_doc, /* tp_doc */ + textiobase_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - TextIOBase_methods, /* tp_methods */ + textiobase_methods, /* tp_methods */ 0, /* tp_members */ - TextIOBase_getset, /* tp_getset */ + textiobase_getset, /* tp_getset */ &PyIOBase_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ @@ -176,7 +176,7 @@ PyTypeObject PyTextIOBase_Type = { /* IncrementalNewlineDecoder */ -PyDoc_STRVAR(IncrementalNewlineDecoder_doc, +PyDoc_STRVAR(incrementalnewlinedecoder_doc, "Codec used when reading a file in universal newlines mode. It wraps\n" "another incremental decoder, translating \\r\\n and \\r into \\n. It also\n" "records the types of newlines encountered. When used with\n" @@ -193,10 +193,10 @@ typedef struct { int pendingcr:1; int translate:1; unsigned int seennl:3; -} PyNewLineDecoderObject; +} nldecoder_object; static int -IncrementalNewlineDecoder_init(PyNewLineDecoderObject *self, +incrementalnewlinedecoder_init(nldecoder_object *self, PyObject *args, PyObject *kwds) { PyObject *decoder; @@ -229,7 +229,7 @@ IncrementalNewlineDecoder_init(PyNewLineDecoderObject *self, } static void -IncrementalNewlineDecoder_dealloc(PyNewLineDecoderObject *self) +incrementalnewlinedecoder_dealloc(nldecoder_object *self) { Py_CLEAR(self->decoder); Py_CLEAR(self->errors); @@ -247,7 +247,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *_self, { PyObject *output; Py_ssize_t output_len; - PyNewLineDecoderObject *self = (PyNewLineDecoderObject *) _self; + nldecoder_object *self = (nldecoder_object *) _self; if (self->decoder == NULL) { PyErr_SetString(PyExc_ValueError, @@ -460,7 +460,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *_self, } static PyObject * -IncrementalNewlineDecoder_decode(PyNewLineDecoderObject *self, +incrementalnewlinedecoder_decode(nldecoder_object *self, PyObject *args, PyObject *kwds) { char *kwlist[] = {"input", "final", NULL}; @@ -474,7 +474,7 @@ IncrementalNewlineDecoder_decode(PyNewLineDecoderObject *self, } static PyObject * -IncrementalNewlineDecoder_getstate(PyNewLineDecoderObject *self, PyObject *args) +incrementalnewlinedecoder_getstate(nldecoder_object *self, PyObject *args) { PyObject *buffer; unsigned PY_LONG_LONG flag; @@ -502,7 +502,7 @@ IncrementalNewlineDecoder_getstate(PyNewLineDecoderObject *self, PyObject *args) } static PyObject * -IncrementalNewlineDecoder_setstate(PyNewLineDecoderObject *self, PyObject *state) +incrementalnewlinedecoder_setstate(nldecoder_object *self, PyObject *state) { PyObject *buffer; unsigned PY_LONG_LONG flag; @@ -521,7 +521,7 @@ IncrementalNewlineDecoder_setstate(PyNewLineDecoderObject *self, PyObject *state } static PyObject * -IncrementalNewlineDecoder_reset(PyNewLineDecoderObject *self, PyObject *args) +incrementalnewlinedecoder_reset(nldecoder_object *self, PyObject *args) { self->seennl = 0; self->pendingcr = 0; @@ -532,7 +532,7 @@ IncrementalNewlineDecoder_reset(PyNewLineDecoderObject *self, PyObject *args) } static PyObject * -IncrementalNewlineDecoder_newlines_get(PyNewLineDecoderObject *self, void *context) +incrementalnewlinedecoder_newlines_get(nldecoder_object *self, void *context) { switch (self->seennl) { case SEEN_CR: @@ -556,25 +556,25 @@ IncrementalNewlineDecoder_newlines_get(PyNewLineDecoderObject *self, void *conte } -static PyMethodDef IncrementalNewlineDecoder_methods[] = { - {"decode", (PyCFunction)IncrementalNewlineDecoder_decode, METH_VARARGS|METH_KEYWORDS}, - {"getstate", (PyCFunction)IncrementalNewlineDecoder_getstate, METH_NOARGS}, - {"setstate", (PyCFunction)IncrementalNewlineDecoder_setstate, METH_O}, - {"reset", (PyCFunction)IncrementalNewlineDecoder_reset, METH_NOARGS}, +static PyMethodDef incrementalnewlinedecoder_methods[] = { + {"decode", (PyCFunction)incrementalnewlinedecoder_decode, METH_VARARGS|METH_KEYWORDS}, + {"getstate", (PyCFunction)incrementalnewlinedecoder_getstate, METH_NOARGS}, + {"setstate", (PyCFunction)incrementalnewlinedecoder_setstate, METH_O}, + {"reset", (PyCFunction)incrementalnewlinedecoder_reset, METH_NOARGS}, {NULL} }; -static PyGetSetDef IncrementalNewlineDecoder_getset[] = { - {"newlines", (getter)IncrementalNewlineDecoder_newlines_get, NULL, NULL}, +static PyGetSetDef incrementalnewlinedecoder_getset[] = { + {"newlines", (getter)incrementalnewlinedecoder_newlines_get, NULL, NULL}, {NULL} }; PyTypeObject PyIncrementalNewlineDecoder_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.IncrementalNewlineDecoder", /*tp_name*/ - sizeof(PyNewLineDecoderObject), /*tp_basicsize*/ + sizeof(nldecoder_object), /*tp_basicsize*/ 0, /*tp_itemsize*/ - (destructor)IncrementalNewlineDecoder_dealloc, /*tp_dealloc*/ + (destructor)incrementalnewlinedecoder_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -590,22 +590,22 @@ PyTypeObject PyIncrementalNewlineDecoder_Type = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - IncrementalNewlineDecoder_doc, /* tp_doc */ + incrementalnewlinedecoder_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /*tp_weaklistoffset*/ 0, /* tp_iter */ 0, /* tp_iternext */ - IncrementalNewlineDecoder_methods, /* tp_methods */ + incrementalnewlinedecoder_methods, /* tp_methods */ 0, /* tp_members */ - IncrementalNewlineDecoder_getset, /* tp_getset */ + incrementalnewlinedecoder_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - (initproc)IncrementalNewlineDecoder_init, /* tp_init */ + (initproc)incrementalnewlinedecoder_init, /* tp_init */ 0, /* tp_alloc */ PyType_GenericNew, /* tp_new */ }; @@ -613,7 +613,7 @@ PyTypeObject PyIncrementalNewlineDecoder_Type = { /* TextIOWrapper */ -PyDoc_STRVAR(TextIOWrapper_doc, +PyDoc_STRVAR(textiowrapper_doc, "Character and line based layer over a BufferedIOBase object, buffer.\n" "\n" "encoding gives the name of the encoding that the stream will be\n" @@ -689,14 +689,14 @@ typedef struct PyObject *weakreflist; PyObject *dict; -} PyTextIOWrapperObject; +} textio; /* A couple of specialized cases in order to bypass the slow incremental encoding methods for the most popular encodings. */ static PyObject * -ascii_encode(PyTextIOWrapperObject *self, PyObject *text) +ascii_encode(textio *self, PyObject *text) { return PyUnicode_EncodeASCII(PyUnicode_AS_UNICODE(text), PyUnicode_GET_SIZE(text), @@ -704,7 +704,7 @@ ascii_encode(PyTextIOWrapperObject *self, PyObject *text) } static PyObject * -utf16be_encode(PyTextIOWrapperObject *self, PyObject *text) +utf16be_encode(textio *self, PyObject *text) { return PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(text), PyUnicode_GET_SIZE(text), @@ -712,7 +712,7 @@ utf16be_encode(PyTextIOWrapperObject *self, PyObject *text) } static PyObject * -utf16le_encode(PyTextIOWrapperObject *self, PyObject *text) +utf16le_encode(textio *self, PyObject *text) { return PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(text), PyUnicode_GET_SIZE(text), @@ -720,7 +720,7 @@ utf16le_encode(PyTextIOWrapperObject *self, PyObject *text) } static PyObject * -utf16_encode(PyTextIOWrapperObject *self, PyObject *text) +utf16_encode(textio *self, PyObject *text) { if (!self->encoding_start_of_stream) { /* Skip the BOM and use native byte ordering */ @@ -736,7 +736,7 @@ utf16_encode(PyTextIOWrapperObject *self, PyObject *text) } static PyObject * -utf32be_encode(PyTextIOWrapperObject *self, PyObject *text) +utf32be_encode(textio *self, PyObject *text) { return PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(text), PyUnicode_GET_SIZE(text), @@ -744,7 +744,7 @@ utf32be_encode(PyTextIOWrapperObject *self, PyObject *text) } static PyObject * -utf32le_encode(PyTextIOWrapperObject *self, PyObject *text) +utf32le_encode(textio *self, PyObject *text) { return PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(text), PyUnicode_GET_SIZE(text), @@ -752,7 +752,7 @@ utf32le_encode(PyTextIOWrapperObject *self, PyObject *text) } static PyObject * -utf32_encode(PyTextIOWrapperObject *self, PyObject *text) +utf32_encode(textio *self, PyObject *text) { if (!self->encoding_start_of_stream) { /* Skip the BOM and use native byte ordering */ @@ -768,7 +768,7 @@ utf32_encode(PyTextIOWrapperObject *self, PyObject *text) } static PyObject * -utf8_encode(PyTextIOWrapperObject *self, PyObject *text) +utf8_encode(textio *self, PyObject *text) { return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(text), PyUnicode_GET_SIZE(text), @@ -776,7 +776,7 @@ utf8_encode(PyTextIOWrapperObject *self, PyObject *text) } static PyObject * -latin1_encode(PyTextIOWrapperObject *self, PyObject *text) +latin1_encode(textio *self, PyObject *text) { return PyUnicode_EncodeLatin1(PyUnicode_AS_UNICODE(text), PyUnicode_GET_SIZE(text), @@ -805,7 +805,7 @@ static encodefuncentry encodefuncs[] = { static int -TextIOWrapper_init(PyTextIOWrapperObject *self, PyObject *args, PyObject *kwds) +textiowrapper_init(textio *self, PyObject *args, PyObject *kwds) { char *kwlist[] = {"buffer", "encoding", "errors", "newline", "line_buffering", @@ -1068,7 +1068,7 @@ TextIOWrapper_init(PyTextIOWrapperObject *self, PyObject *args, PyObject *kwds) } static int -_TextIOWrapper_clear(PyTextIOWrapperObject *self) +_textiowrapper_clear(textio *self) { if (self->ok && _PyIOBase_finalize((PyObject *) self) < 0) return -1; @@ -1087,9 +1087,9 @@ _TextIOWrapper_clear(PyTextIOWrapperObject *self) } static void -TextIOWrapper_dealloc(PyTextIOWrapperObject *self) +textiowrapper_dealloc(textio *self) { - if (_TextIOWrapper_clear(self) < 0) + if (_textiowrapper_clear(self) < 0) return; _PyObject_GC_UNTRACK(self); if (self->weakreflist != NULL) @@ -1099,7 +1099,7 @@ TextIOWrapper_dealloc(PyTextIOWrapperObject *self) } static int -TextIOWrapper_traverse(PyTextIOWrapperObject *self, visitproc visit, void *arg) +textiowrapper_traverse(textio *self, visitproc visit, void *arg) { Py_VISIT(self->buffer); Py_VISIT(self->encoding); @@ -1117,16 +1117,16 @@ TextIOWrapper_traverse(PyTextIOWrapperObject *self, visitproc visit, void *arg) } static int -TextIOWrapper_clear(PyTextIOWrapperObject *self) +textiowrapper_clear(textio *self) { - if (_TextIOWrapper_clear(self) < 0) + if (_textiowrapper_clear(self) < 0) return -1; Py_CLEAR(self->dict); return 0; } static PyObject * -TextIOWrapper_closed_get(PyTextIOWrapperObject *self, void *context); +textiowrapper_closed_get(textio *self, void *context); /* This macro takes some shortcuts to make the common case faster. */ #define CHECK_CLOSED(self) \ @@ -1137,7 +1137,7 @@ TextIOWrapper_closed_get(PyTextIOWrapperObject *self, void *context); if (self->raw != NULL) \ r = _PyFileIO_closed(self->raw); \ else { \ - _res = TextIOWrapper_closed_get(self, NULL); \ + _res = textiowrapper_closed_get(self, NULL); \ if (_res == NULL) \ return NULL; \ r = PyObject_IsTrue(_res); \ @@ -1151,7 +1151,7 @@ TextIOWrapper_closed_get(PyTextIOWrapperObject *self, void *context); return NULL; \ } \ } \ - else if (_PyIOBase_checkClosed((PyObject *)self, Py_True) == NULL) \ + else if (_PyIOBase_check_closed((PyObject *)self, Py_True) == NULL) \ return NULL; \ } while (0) @@ -1181,7 +1181,7 @@ TextIOWrapper_closed_get(PyTextIOWrapperObject *self, void *context); static PyObject * -TextIOWrapper_detach(PyTextIOWrapperObject *self) +textiowrapper_detach(textio *self) { PyObject *buffer, *res; CHECK_INITIALIZED(self); @@ -1211,7 +1211,7 @@ findchar(const Py_UNICODE *s, Py_ssize_t size, Py_UNICODE ch) /* Flush the internal write buffer. This doesn't explicitly flush the underlying buffered object, though. */ static int -_TextIOWrapper_writeflush(PyTextIOWrapperObject *self) +_textiowrapper_writeflush(textio *self) { PyObject *b, *ret; @@ -1232,7 +1232,7 @@ _TextIOWrapper_writeflush(PyTextIOWrapperObject *self) } static PyObject * -TextIOWrapper_write(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_write(textio *self, PyObject *args) { PyObject *ret; PyObject *text; /* owned reference */ @@ -1305,7 +1305,7 @@ TextIOWrapper_write(PyTextIOWrapperObject *self, PyObject *args) self->pending_bytes_count += PyBytes_GET_SIZE(b); Py_DECREF(b); if (self->pending_bytes_count > self->chunk_size || needflush) { - if (_TextIOWrapper_writeflush(self) < 0) + if (_textiowrapper_writeflush(self) < 0) return NULL; } @@ -1331,7 +1331,7 @@ TextIOWrapper_write(PyTextIOWrapperObject *self, PyObject *args) /* Steal a reference to chars and store it in the decoded_char buffer; */ static void -TextIOWrapper_set_decoded_chars(PyTextIOWrapperObject *self, PyObject *chars) +textiowrapper_set_decoded_chars(textio *self, PyObject *chars) { Py_CLEAR(self->decoded_chars); self->decoded_chars = chars; @@ -1339,7 +1339,7 @@ TextIOWrapper_set_decoded_chars(PyTextIOWrapperObject *self, PyObject *chars) } static PyObject * -TextIOWrapper_get_decoded_chars(PyTextIOWrapperObject *self, Py_ssize_t n) +textiowrapper_get_decoded_chars(textio *self, Py_ssize_t n) { PyObject *chars; Py_ssize_t avail; @@ -1374,7 +1374,7 @@ TextIOWrapper_get_decoded_chars(PyTextIOWrapperObject *self, Py_ssize_t n) /* Read and decode the next chunk of data from the BufferedReader. */ static int -TextIOWrapper_read_chunk(PyTextIOWrapperObject *self) +textiowrapper_read_chunk(textio *self) { PyObject *dec_buffer = NULL; PyObject *dec_flags = NULL; @@ -1439,7 +1439,7 @@ TextIOWrapper_read_chunk(PyTextIOWrapperObject *self) /* TODO sanity check: isinstance(decoded_chars, unicode) */ if (decoded_chars == NULL) goto fail; - TextIOWrapper_set_decoded_chars(self, decoded_chars); + textiowrapper_set_decoded_chars(self, decoded_chars); if (PyUnicode_GET_SIZE(decoded_chars) > 0) eof = 0; @@ -1467,7 +1467,7 @@ TextIOWrapper_read_chunk(PyTextIOWrapperObject *self) } static PyObject * -TextIOWrapper_read(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_read(textio *self, PyObject *args) { Py_ssize_t n = -1; PyObject *result = NULL, *chunks = NULL; @@ -1484,7 +1484,7 @@ TextIOWrapper_read(PyTextIOWrapperObject *self, PyObject *args) return NULL; } - if (_TextIOWrapper_writeflush(self) < 0) + if (_textiowrapper_writeflush(self) < 0) return NULL; if (n < 0) { @@ -1499,7 +1499,7 @@ TextIOWrapper_read(PyTextIOWrapperObject *self, PyObject *args) if (decoded == NULL) goto fail; - result = TextIOWrapper_get_decoded_chars(self, -1); + result = textiowrapper_get_decoded_chars(self, -1); if (result == NULL) { Py_DECREF(decoded); @@ -1517,14 +1517,14 @@ TextIOWrapper_read(PyTextIOWrapperObject *self, PyObject *args) int res = 1; Py_ssize_t remaining = n; - result = TextIOWrapper_get_decoded_chars(self, n); + result = textiowrapper_get_decoded_chars(self, n); if (result == NULL) goto fail; remaining -= PyUnicode_GET_SIZE(result); /* Keep reading chunks until we have n characters to return */ while (remaining > 0) { - res = TextIOWrapper_read_chunk(self); + res = textiowrapper_read_chunk(self); if (res < 0) goto fail; if (res == 0) /* EOF */ @@ -1537,7 +1537,7 @@ TextIOWrapper_read(PyTextIOWrapperObject *self, PyObject *args) if (PyList_Append(chunks, result) < 0) goto fail; Py_DECREF(result); - result = TextIOWrapper_get_decoded_chars(self, remaining); + result = textiowrapper_get_decoded_chars(self, remaining); if (result == NULL) goto fail; remaining -= PyUnicode_GET_SIZE(result); @@ -1662,7 +1662,7 @@ _PyIO_find_line_ending( } static PyObject * -_TextIOWrapper_readline(PyTextIOWrapperObject *self, Py_ssize_t limit) +_textiowrapper_readline(textio *self, Py_ssize_t limit) { PyObject *line = NULL, *chunks = NULL, *remaining = NULL; Py_ssize_t start, endpos, chunked, offset_to_buffer; @@ -1670,7 +1670,7 @@ _TextIOWrapper_readline(PyTextIOWrapperObject *self, Py_ssize_t limit) CHECK_CLOSED(self); - if (_TextIOWrapper_writeflush(self) < 0) + if (_textiowrapper_writeflush(self) < 0) return NULL; chunked = 0; @@ -1684,7 +1684,7 @@ _TextIOWrapper_readline(PyTextIOWrapperObject *self, Py_ssize_t limit) res = 1; while (!self->decoded_chars || !PyUnicode_GET_SIZE(self->decoded_chars)) { - res = TextIOWrapper_read_chunk(self); + res = textiowrapper_read_chunk(self); if (res < 0) goto error; if (res == 0) @@ -1692,7 +1692,7 @@ _TextIOWrapper_readline(PyTextIOWrapperObject *self, Py_ssize_t limit) } if (res == 0) { /* end of file */ - TextIOWrapper_set_decoded_chars(self, NULL); + textiowrapper_set_decoded_chars(self, NULL); Py_CLEAR(self->snapshot); start = endpos = offset_to_buffer = 0; break; @@ -1763,7 +1763,7 @@ _TextIOWrapper_readline(PyTextIOWrapperObject *self, Py_ssize_t limit) } Py_CLEAR(line); /* We have consumed the buffer */ - TextIOWrapper_set_decoded_chars(self, NULL); + textiowrapper_set_decoded_chars(self, NULL); } if (line != NULL) { @@ -1816,7 +1816,7 @@ _TextIOWrapper_readline(PyTextIOWrapperObject *self, Py_ssize_t limit) } static PyObject * -TextIOWrapper_readline(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_readline(textio *self, PyObject *args) { Py_ssize_t limit = -1; @@ -1824,7 +1824,7 @@ TextIOWrapper_readline(PyTextIOWrapperObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "|n:readline", &limit)) { return NULL; } - return _TextIOWrapper_readline(self, limit); + return _textiowrapper_readline(self, limit); } /* Seek and Tell */ @@ -1835,7 +1835,7 @@ typedef struct { int bytes_to_feed; int chars_to_skip; char need_eof; -} CookieStruct; +} cookie_type; /* To speed up cookie packing/unpacking, we store the fields in a temporary @@ -1876,7 +1876,7 @@ typedef struct { #endif static int -TextIOWrapper_parseCookie(CookieStruct *cookie, PyObject *cookieObj) +textiowrapper_parse_cookie(cookie_type *cookie, PyObject *cookieObj) { unsigned char buffer[COOKIE_BUF_LEN]; PyLongObject *cookieLong = (PyLongObject *)PyNumber_Long(cookieObj); @@ -1900,7 +1900,7 @@ TextIOWrapper_parseCookie(CookieStruct *cookie, PyObject *cookieObj) } static PyObject * -TextIOWrapper_buildCookie(CookieStruct *cookie) +textiowrapper_build_cookie(cookie_type *cookie) { unsigned char buffer[COOKIE_BUF_LEN]; @@ -1915,8 +1915,7 @@ TextIOWrapper_buildCookie(CookieStruct *cookie) #undef IS_LITTLE_ENDIAN static int -_TextIOWrapper_decoder_setstate(PyTextIOWrapperObject *self, - CookieStruct *cookie) +_textiowrapper_decoder_setstate(textio *self, cookie_type *cookie) { PyObject *res; /* When seeking to the start of the stream, we call decoder.reset() @@ -1937,11 +1936,10 @@ _TextIOWrapper_decoder_setstate(PyTextIOWrapperObject *self, } static int -_TextIOWrapper_encoder_setstate(PyTextIOWrapperObject *self, - CookieStruct *cookie) +_textiowrapper_encoder_setstate(textio *self, cookie_type *cookie) { PyObject *res; - /* Same as _TextIOWrapper_decoder_setstate() above. */ + /* Same as _textiowrapper_decoder_setstate() above. */ if (cookie->start_pos == 0 && cookie->dec_flags == 0) { res = PyObject_CallMethodObjArgs(self->encoder, _PyIO_str_reset, NULL); self->encoding_start_of_stream = 1; @@ -1958,10 +1956,10 @@ _TextIOWrapper_encoder_setstate(PyTextIOWrapperObject *self, } static PyObject * -TextIOWrapper_seek(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_seek(textio *self, PyObject *args) { PyObject *cookieObj, *posobj; - CookieStruct cookie; + cookie_type cookie; int whence = 0; PyObject *res; int cmp; @@ -2018,7 +2016,7 @@ TextIOWrapper_seek(PyTextIOWrapperObject *self, PyObject *args) goto fail; Py_DECREF(res); - TextIOWrapper_set_decoded_chars(self, NULL); + textiowrapper_set_decoded_chars(self, NULL); Py_CLEAR(self->snapshot); if (self->decoder) { res = PyObject_CallMethod(self->decoder, "reset", NULL); @@ -2055,7 +2053,7 @@ TextIOWrapper_seek(PyTextIOWrapperObject *self, PyObject *args) /* The strategy of seek() is to go back to the safe start point * and replay the effect of read(chars_to_skip) from there. */ - if (TextIOWrapper_parseCookie(&cookie, cookieObj) < 0) + if (textiowrapper_parse_cookie(&cookie, cookieObj) < 0) goto fail; /* Seek back to the safe start point. */ @@ -2069,12 +2067,12 @@ TextIOWrapper_seek(PyTextIOWrapperObject *self, PyObject *args) goto fail; Py_DECREF(res); - TextIOWrapper_set_decoded_chars(self, NULL); + textiowrapper_set_decoded_chars(self, NULL); Py_CLEAR(self->snapshot); /* Restore the decoder to its state from the safe start point. */ if (self->decoder) { - if (_TextIOWrapper_decoder_setstate(self, &cookie) < 0) + if (_textiowrapper_decoder_setstate(self, &cookie) < 0) goto fail; } @@ -2101,7 +2099,7 @@ TextIOWrapper_seek(PyTextIOWrapperObject *self, PyObject *args) if (decoded == NULL) goto fail; - TextIOWrapper_set_decoded_chars(self, decoded); + textiowrapper_set_decoded_chars(self, decoded); /* Skip chars_to_skip of the decoded characters. */ if (PyUnicode_GetSize(self->decoded_chars) < cookie.chars_to_skip) { @@ -2118,7 +2116,7 @@ TextIOWrapper_seek(PyTextIOWrapperObject *self, PyObject *args) /* Finally, reset the encoder (merely useful for proper BOM handling) */ if (self->encoder) { - if (_TextIOWrapper_encoder_setstate(self, &cookie) < 0) + if (_textiowrapper_encoder_setstate(self, &cookie) < 0) goto fail; } return cookieObj; @@ -2129,11 +2127,11 @@ TextIOWrapper_seek(PyTextIOWrapperObject *self, PyObject *args) } static PyObject * -TextIOWrapper_tell(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_tell(textio *self, PyObject *args) { PyObject *res; PyObject *posobj = NULL; - CookieStruct cookie = {0,0,0,0,0}; + cookie_type cookie = {0,0,0,0,0}; PyObject *next_input; Py_ssize_t chars_to_skip, chars_decoded; PyObject *saved_state = NULL; @@ -2153,7 +2151,7 @@ TextIOWrapper_tell(PyTextIOWrapperObject *self, PyObject *args) goto fail; } - if (_TextIOWrapper_writeflush(self) < 0) + if (_textiowrapper_writeflush(self) < 0) return NULL; res = PyObject_CallMethod((PyObject *)self, "flush", NULL); if (res == NULL) @@ -2189,7 +2187,7 @@ TextIOWrapper_tell(PyTextIOWrapperObject *self, PyObject *args) if (self->decoded_chars_used == 0) { /* We haven't moved from the snapshot point. */ Py_DECREF(posobj); - return TextIOWrapper_buildCookie(&cookie); + return textiowrapper_build_cookie(&cookie); } chars_to_skip = self->decoded_chars_used; @@ -2203,7 +2201,7 @@ TextIOWrapper_tell(PyTextIOWrapperObject *self, PyObject *args) goto fail; /* Note our initial start point. */ - if (_TextIOWrapper_decoder_setstate(self, &cookie) < 0) + if (_textiowrapper_decoder_setstate(self, &cookie) < 0) goto fail; /* Feed the decoder one byte at a time. As we go, note the @@ -2280,7 +2278,7 @@ TextIOWrapper_tell(PyTextIOWrapperObject *self, PyObject *args) /* The returned cookie corresponds to the last safe start point. */ cookie.chars_to_skip = Py_SAFE_DOWNCAST(chars_to_skip, Py_ssize_t, int); - return TextIOWrapper_buildCookie(&cookie); + return textiowrapper_build_cookie(&cookie); fail: Py_XDECREF(posobj); @@ -2300,7 +2298,7 @@ TextIOWrapper_tell(PyTextIOWrapperObject *self, PyObject *args) } static PyObject * -TextIOWrapper_truncate(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_truncate(textio *self, PyObject *args) { PyObject *pos = Py_None; PyObject *res; @@ -2327,7 +2325,7 @@ TextIOWrapper_truncate(PyTextIOWrapperObject *self, PyObject *args) } static PyObject * -TextIOWrapper_repr(PyTextIOWrapperObject *self) +textiowrapper_repr(textio *self) { PyObject *nameobj, *res; @@ -2354,53 +2352,53 @@ TextIOWrapper_repr(PyTextIOWrapperObject *self) /* Inquiries */ static PyObject * -TextIOWrapper_fileno(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_fileno(textio *self, PyObject *args) { CHECK_INITIALIZED(self); return PyObject_CallMethod(self->buffer, "fileno", NULL); } static PyObject * -TextIOWrapper_seekable(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_seekable(textio *self, PyObject *args) { CHECK_INITIALIZED(self); return PyObject_CallMethod(self->buffer, "seekable", NULL); } static PyObject * -TextIOWrapper_readable(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_readable(textio *self, PyObject *args) { CHECK_INITIALIZED(self); return PyObject_CallMethod(self->buffer, "readable", NULL); } static PyObject * -TextIOWrapper_writable(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_writable(textio *self, PyObject *args) { CHECK_INITIALIZED(self); return PyObject_CallMethod(self->buffer, "writable", NULL); } static PyObject * -TextIOWrapper_isatty(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_isatty(textio *self, PyObject *args) { CHECK_INITIALIZED(self); return PyObject_CallMethod(self->buffer, "isatty", NULL); } static PyObject * -TextIOWrapper_flush(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_flush(textio *self, PyObject *args) { CHECK_INITIALIZED(self); CHECK_CLOSED(self); self->telling = self->seekable; - if (_TextIOWrapper_writeflush(self) < 0) + if (_textiowrapper_writeflush(self) < 0) return NULL; return PyObject_CallMethod(self->buffer, "flush", NULL); } static PyObject * -TextIOWrapper_close(PyTextIOWrapperObject *self, PyObject *args) +textiowrapper_close(textio *self, PyObject *args) { PyObject *res; CHECK_INITIALIZED(self); @@ -2416,7 +2414,7 @@ TextIOWrapper_close(PyTextIOWrapperObject *self, PyObject *args) } static PyObject * -TextIOWrapper_iternext(PyTextIOWrapperObject *self) +textiowrapper_iternext(textio *self) { PyObject *line; @@ -2425,7 +2423,7 @@ TextIOWrapper_iternext(PyTextIOWrapperObject *self) self->telling = 0; if (Py_TYPE(self) == &PyTextIOWrapper_Type) { /* Skip method call overhead for speed */ - line = _TextIOWrapper_readline(self, -1); + line = _textiowrapper_readline(self, -1); } else { line = PyObject_CallMethodObjArgs((PyObject *)self, @@ -2454,21 +2452,21 @@ TextIOWrapper_iternext(PyTextIOWrapperObject *self) } static PyObject * -TextIOWrapper_name_get(PyTextIOWrapperObject *self, void *context) +textiowrapper_name_get(textio *self, void *context) { CHECK_INITIALIZED(self); return PyObject_GetAttrString(self->buffer, "name"); } static PyObject * -TextIOWrapper_closed_get(PyTextIOWrapperObject *self, void *context) +textiowrapper_closed_get(textio *self, void *context) { CHECK_INITIALIZED(self); return PyObject_GetAttr(self->buffer, _PyIO_str_closed); } static PyObject * -TextIOWrapper_newlines_get(PyTextIOWrapperObject *self, void *context) +textiowrapper_newlines_get(textio *self, void *context) { PyObject *res; CHECK_INITIALIZED(self); @@ -2488,22 +2486,21 @@ TextIOWrapper_newlines_get(PyTextIOWrapperObject *self, void *context) } static PyObject * -TextIOWrapper_errors_get(PyTextIOWrapperObject *self, void *context) +textiowrapper_errors_get(textio *self, void *context) { CHECK_INITIALIZED(self); return PyUnicode_FromString(PyBytes_AS_STRING(self->errors)); } static PyObject * -TextIOWrapper_chunk_size_get(PyTextIOWrapperObject *self, void *context) +textiowrapper_chunk_size_get(textio *self, void *context) { CHECK_INITIALIZED(self); return PyLong_FromSsize_t(self->chunk_size); } static int -TextIOWrapper_chunk_size_set(PyTextIOWrapperObject *self, - PyObject *arg, void *context) +textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context) { Py_ssize_t n; CHECK_INITIALIZED_INT(self); @@ -2519,56 +2516,56 @@ TextIOWrapper_chunk_size_set(PyTextIOWrapperObject *self, return 0; } -static PyMethodDef TextIOWrapper_methods[] = { - {"detach", (PyCFunction)TextIOWrapper_detach, METH_NOARGS}, - {"write", (PyCFunction)TextIOWrapper_write, METH_VARARGS}, - {"read", (PyCFunction)TextIOWrapper_read, METH_VARARGS}, - {"readline", (PyCFunction)TextIOWrapper_readline, METH_VARARGS}, - {"flush", (PyCFunction)TextIOWrapper_flush, METH_NOARGS}, - {"close", (PyCFunction)TextIOWrapper_close, METH_NOARGS}, +static PyMethodDef textiowrapper_methods[] = { + {"detach", (PyCFunction)textiowrapper_detach, METH_NOARGS}, + {"write", (PyCFunction)textiowrapper_write, METH_VARARGS}, + {"read", (PyCFunction)textiowrapper_read, METH_VARARGS}, + {"readline", (PyCFunction)textiowrapper_readline, METH_VARARGS}, + {"flush", (PyCFunction)textiowrapper_flush, METH_NOARGS}, + {"close", (PyCFunction)textiowrapper_close, METH_NOARGS}, - {"fileno", (PyCFunction)TextIOWrapper_fileno, METH_NOARGS}, - {"seekable", (PyCFunction)TextIOWrapper_seekable, METH_NOARGS}, - {"readable", (PyCFunction)TextIOWrapper_readable, METH_NOARGS}, - {"writable", (PyCFunction)TextIOWrapper_writable, METH_NOARGS}, - {"isatty", (PyCFunction)TextIOWrapper_isatty, METH_NOARGS}, + {"fileno", (PyCFunction)textiowrapper_fileno, METH_NOARGS}, + {"seekable", (PyCFunction)textiowrapper_seekable, METH_NOARGS}, + {"readable", (PyCFunction)textiowrapper_readable, METH_NOARGS}, + {"writable", (PyCFunction)textiowrapper_writable, METH_NOARGS}, + {"isatty", (PyCFunction)textiowrapper_isatty, METH_NOARGS}, - {"seek", (PyCFunction)TextIOWrapper_seek, METH_VARARGS}, - {"tell", (PyCFunction)TextIOWrapper_tell, METH_NOARGS}, - {"truncate", (PyCFunction)TextIOWrapper_truncate, METH_VARARGS}, + {"seek", (PyCFunction)textiowrapper_seek, METH_VARARGS}, + {"tell", (PyCFunction)textiowrapper_tell, METH_NOARGS}, + {"truncate", (PyCFunction)textiowrapper_truncate, METH_VARARGS}, {NULL, NULL} }; -static PyMemberDef TextIOWrapper_members[] = { - {"encoding", T_OBJECT, offsetof(PyTextIOWrapperObject, encoding), READONLY}, - {"buffer", T_OBJECT, offsetof(PyTextIOWrapperObject, buffer), READONLY}, - {"line_buffering", T_BOOL, offsetof(PyTextIOWrapperObject, line_buffering), READONLY}, +static PyMemberDef textiowrapper_members[] = { + {"encoding", T_OBJECT, offsetof(textio, encoding), READONLY}, + {"buffer", T_OBJECT, offsetof(textio, buffer), READONLY}, + {"line_buffering", T_BOOL, offsetof(textio, line_buffering), READONLY}, {NULL} }; -static PyGetSetDef TextIOWrapper_getset[] = { - {"name", (getter)TextIOWrapper_name_get, NULL, NULL}, - {"closed", (getter)TextIOWrapper_closed_get, NULL, NULL}, +static PyGetSetDef textiowrapper_getset[] = { + {"name", (getter)textiowrapper_name_get, NULL, NULL}, + {"closed", (getter)textiowrapper_closed_get, NULL, NULL}, /* {"mode", (getter)TextIOWrapper_mode_get, NULL, NULL}, */ - {"newlines", (getter)TextIOWrapper_newlines_get, NULL, NULL}, - {"errors", (getter)TextIOWrapper_errors_get, NULL, NULL}, - {"_CHUNK_SIZE", (getter)TextIOWrapper_chunk_size_get, - (setter)TextIOWrapper_chunk_size_set, NULL}, + {"newlines", (getter)textiowrapper_newlines_get, NULL, NULL}, + {"errors", (getter)textiowrapper_errors_get, NULL, NULL}, + {"_CHUNK_SIZE", (getter)textiowrapper_chunk_size_get, + (setter)textiowrapper_chunk_size_set, NULL}, {NULL} }; PyTypeObject PyTextIOWrapper_Type = { PyVarObject_HEAD_INIT(NULL, 0) "_io.TextIOWrapper", /*tp_name*/ - sizeof(PyTextIOWrapperObject), /*tp_basicsize*/ + sizeof(textio), /*tp_basicsize*/ 0, /*tp_itemsize*/ - (destructor)TextIOWrapper_dealloc, /*tp_dealloc*/ + (destructor)textiowrapper_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tps_etattr*/ 0, /*tp_compare */ - (reprfunc)TextIOWrapper_repr,/*tp_repr*/ + (reprfunc)textiowrapper_repr,/*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -2580,22 +2577,22 @@ PyTypeObject PyTextIOWrapper_Type = { 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - TextIOWrapper_doc, /* tp_doc */ - (traverseproc)TextIOWrapper_traverse, /* tp_traverse */ - (inquiry)TextIOWrapper_clear, /* tp_clear */ + textiowrapper_doc, /* tp_doc */ + (traverseproc)textiowrapper_traverse, /* tp_traverse */ + (inquiry)textiowrapper_clear, /* tp_clear */ 0, /* tp_richcompare */ - offsetof(PyTextIOWrapperObject, weakreflist), /*tp_weaklistoffset*/ + offsetof(textio, weakreflist), /*tp_weaklistoffset*/ 0, /* tp_iter */ - (iternextfunc)TextIOWrapper_iternext, /* tp_iternext */ - TextIOWrapper_methods, /* tp_methods */ - TextIOWrapper_members, /* tp_members */ - TextIOWrapper_getset, /* tp_getset */ + (iternextfunc)textiowrapper_iternext, /* tp_iternext */ + textiowrapper_methods, /* tp_methods */ + textiowrapper_members, /* tp_members */ + textiowrapper_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - offsetof(PyTextIOWrapperObject, dict), /*tp_dictoffset*/ - (initproc)TextIOWrapper_init, /* tp_init */ + offsetof(textio, dict), /*tp_dictoffset*/ + (initproc)textiowrapper_init, /* tp_init */ 0, /* tp_alloc */ PyType_GenericNew, /* tp_new */ }; |