Kaydet (Commit) 680bf1af authored tarafından Benjamin Peterson's avatar Benjamin Peterson

move to a naming scheme with all lowercase and underscores

üst 2c3ac6b8
...@@ -94,7 +94,7 @@ PyDoc_STRVAR(module_doc, ...@@ -94,7 +94,7 @@ PyDoc_STRVAR(module_doc,
*/ */
static int static int
BlockingIOError_init(PyBlockingIOErrorObject *self, PyObject *args, blockingioerror_init(PyBlockingIOErrorObject *self, PyObject *args,
PyObject *kwds) PyObject *kwds)
{ {
PyObject *myerrno = NULL, *strerror = NULL; PyObject *myerrno = NULL, *strerror = NULL;
...@@ -123,7 +123,7 @@ BlockingIOError_init(PyBlockingIOErrorObject *self, PyObject *args, ...@@ -123,7 +123,7 @@ BlockingIOError_init(PyBlockingIOErrorObject *self, PyObject *args,
return 0; return 0;
} }
static PyMemberDef BlockingIOError_members[] = { static PyMemberDef blockingioerror_members[] = {
{"characters_written", T_PYSSIZET, offsetof(PyBlockingIOErrorObject, written), 0}, {"characters_written", T_PYSSIZET, offsetof(PyBlockingIOErrorObject, written), 0},
{NULL} /* Sentinel */ {NULL} /* Sentinel */
}; };
...@@ -158,14 +158,14 @@ static PyTypeObject _PyExc_BlockingIOError = { ...@@ -158,14 +158,14 @@ static PyTypeObject _PyExc_BlockingIOError = {
0, /* tp_iter */ 0, /* tp_iter */
0, /* tp_iternext */ 0, /* tp_iternext */
0, /* tp_methods */ 0, /* tp_methods */
BlockingIOError_members, /* tp_members */ blockingioerror_members, /* tp_members */
0, /* tp_getset */ 0, /* tp_getset */
0, /* tp_base */ 0, /* tp_base */
0, /* tp_dict */ 0, /* tp_dict */
0, /* tp_descr_get */ 0, /* tp_descr_get */
0, /* tp_descr_set */ 0, /* tp_descr_set */
0, /* tp_dictoffset */ 0, /* tp_dictoffset */
(initproc)BlockingIOError_init, /* tp_init */ (initproc)blockingioerror_init, /* tp_init */
0, /* tp_alloc */ 0, /* tp_alloc */
0, /* tp_new */ 0, /* tp_new */
}; };
......
...@@ -23,10 +23,10 @@ extern PyTypeObject PyIncrementalNewlineDecoder_Type; ...@@ -23,10 +23,10 @@ extern PyTypeObject PyIncrementalNewlineDecoder_Type;
* with args=NULL, and return a new reference. * with args=NULL, and return a new reference.
* BUT when args=Py_True is passed, they return a borrowed reference. * BUT when args=Py_True is passed, they return a borrowed reference.
*/ */
extern PyObject* _PyIOBase_checkReadable(PyObject *self, PyObject *args); extern PyObject* _PyIOBase_check_readable(PyObject *self, PyObject *args);
extern PyObject* _PyIOBase_checkWritable(PyObject *self, PyObject *args); extern PyObject* _PyIOBase_check_writable(PyObject *self, PyObject *args);
extern PyObject* _PyIOBase_checkSeekable(PyObject *self, PyObject *args); extern PyObject* _PyIOBase_check_seekable(PyObject *self, PyObject *args);
extern PyObject* _PyIOBase_checkClosed(PyObject *self, PyObject *args); extern PyObject* _PyIOBase_check_closed(PyObject *self, PyObject *args);
/* Helper for finalization. /* Helper for finalization.
This function will revive an object ready to be deallocated and try to This function will revive an object ready to be deallocated and try to
......
This diff is collapsed.
...@@ -10,7 +10,7 @@ typedef struct { ...@@ -10,7 +10,7 @@ typedef struct {
size_t buf_size; size_t buf_size;
PyObject *dict; PyObject *dict;
PyObject *weakreflist; PyObject *weakreflist;
} BytesIOObject; } bytesio;
#define CHECK_CLOSED(self) \ #define CHECK_CLOSED(self) \
if ((self)->buf == NULL) { \ if ((self)->buf == NULL) { \
...@@ -23,7 +23,7 @@ typedef struct { ...@@ -23,7 +23,7 @@ typedef struct {
object. Returns the length between the current position to the object. Returns the length between the current position to the
next newline character. */ next newline character. */
static Py_ssize_t static Py_ssize_t
get_line(BytesIOObject *self, char **output) get_line(bytesio *self, char **output)
{ {
char *n; char *n;
const char *str_end; const char *str_end;
...@@ -56,7 +56,7 @@ get_line(BytesIOObject *self, char **output) ...@@ -56,7 +56,7 @@ get_line(BytesIOObject *self, char **output)
The caller should ensure that the 'size' argument is non-negative. Returns The caller should ensure that the 'size' argument is non-negative. Returns
0 on success, -1 otherwise. */ 0 on success, -1 otherwise. */
static int 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 /* Here, unsigned types are used to avoid dealing with signed integer
overflow, which is undefined in C. */ overflow, which is undefined in C. */
...@@ -108,7 +108,7 @@ resize_buffer(BytesIOObject *self, size_t size) ...@@ -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 /* 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. */ object. Returns the number of bytes wrote, or -1 on error. */
static Py_ssize_t 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->buf != NULL);
assert(self->pos >= 0); assert(self->pos >= 0);
...@@ -146,7 +146,7 @@ write_bytes(BytesIOObject *self, const char *bytes, Py_ssize_t len) ...@@ -146,7 +146,7 @@ write_bytes(BytesIOObject *self, const char *bytes, Py_ssize_t len)
} }
static PyObject * static PyObject *
bytesio_get_closed(BytesIOObject *self) bytesio_get_closed(bytesio *self)
{ {
if (self->buf == NULL) { if (self->buf == NULL) {
Py_RETURN_TRUE; Py_RETURN_TRUE;
...@@ -158,7 +158,7 @@ bytesio_get_closed(BytesIOObject *self) ...@@ -158,7 +158,7 @@ bytesio_get_closed(BytesIOObject *self)
/* Generic getter for the writable, readable and seekable properties */ /* Generic getter for the writable, readable and seekable properties */
static PyObject * static PyObject *
return_true(BytesIOObject *self) return_true(bytesio *self)
{ {
Py_RETURN_TRUE; Py_RETURN_TRUE;
} }
...@@ -167,7 +167,7 @@ PyDoc_STRVAR(flush_doc, ...@@ -167,7 +167,7 @@ PyDoc_STRVAR(flush_doc,
"flush() -> None. Does nothing."); "flush() -> None. Does nothing.");
static PyObject * static PyObject *
bytesio_flush(BytesIOObject *self) bytesio_flush(bytesio *self)
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
...@@ -178,7 +178,7 @@ PyDoc_STRVAR(getval_doc, ...@@ -178,7 +178,7 @@ PyDoc_STRVAR(getval_doc,
"Retrieve the entire contents of the BytesIO object."); "Retrieve the entire contents of the BytesIO object.");
static PyObject * static PyObject *
bytesio_getvalue(BytesIOObject *self) bytesio_getvalue(bytesio *self)
{ {
CHECK_CLOSED(self); CHECK_CLOSED(self);
return PyBytes_FromStringAndSize(self->buf, self->string_size); return PyBytes_FromStringAndSize(self->buf, self->string_size);
...@@ -191,7 +191,7 @@ PyDoc_STRVAR(isatty_doc, ...@@ -191,7 +191,7 @@ PyDoc_STRVAR(isatty_doc,
"to a tty-like device."); "to a tty-like device.");
static PyObject * static PyObject *
bytesio_isatty(BytesIOObject *self) bytesio_isatty(bytesio *self)
{ {
CHECK_CLOSED(self); CHECK_CLOSED(self);
Py_RETURN_FALSE; Py_RETURN_FALSE;
...@@ -201,7 +201,7 @@ PyDoc_STRVAR(tell_doc, ...@@ -201,7 +201,7 @@ PyDoc_STRVAR(tell_doc,
"tell() -> current file position, an integer\n"); "tell() -> current file position, an integer\n");
static PyObject * static PyObject *
bytesio_tell(BytesIOObject *self) bytesio_tell(bytesio *self)
{ {
CHECK_CLOSED(self); CHECK_CLOSED(self);
return PyLong_FromSsize_t(self->pos); return PyLong_FromSsize_t(self->pos);
...@@ -214,7 +214,7 @@ PyDoc_STRVAR(read_doc, ...@@ -214,7 +214,7 @@ PyDoc_STRVAR(read_doc,
"Return an empty string at EOF."); "Return an empty string at EOF.");
static PyObject * static PyObject *
bytesio_read(BytesIOObject *self, PyObject *args) bytesio_read(bytesio *self, PyObject *args)
{ {
Py_ssize_t size, n; Py_ssize_t size, n;
char *output; char *output;
...@@ -263,7 +263,7 @@ PyDoc_STRVAR(read1_doc, ...@@ -263,7 +263,7 @@ PyDoc_STRVAR(read1_doc,
"Return an empty string at EOF."); "Return an empty string at EOF.");
static PyObject * static PyObject *
bytesio_read1(BytesIOObject *self, PyObject *n) bytesio_read1(bytesio *self, PyObject *n)
{ {
PyObject *arg, *res; PyObject *arg, *res;
...@@ -283,7 +283,7 @@ PyDoc_STRVAR(readline_doc, ...@@ -283,7 +283,7 @@ PyDoc_STRVAR(readline_doc,
"Return an empty string at EOF.\n"); "Return an empty string at EOF.\n");
static PyObject * static PyObject *
bytesio_readline(BytesIOObject *self, PyObject *args) bytesio_readline(bytesio *self, PyObject *args)
{ {
Py_ssize_t size, n; Py_ssize_t size, n;
char *output; char *output;
...@@ -328,7 +328,7 @@ PyDoc_STRVAR(readlines_doc, ...@@ -328,7 +328,7 @@ PyDoc_STRVAR(readlines_doc,
"total number of bytes in the lines returned.\n"); "total number of bytes in the lines returned.\n");
static PyObject * static PyObject *
bytesio_readlines(BytesIOObject *self, PyObject *args) bytesio_readlines(bytesio *self, PyObject *args)
{ {
Py_ssize_t maxsize, size, n; Py_ssize_t maxsize, size, n;
PyObject *result, *line; PyObject *result, *line;
...@@ -387,7 +387,7 @@ PyDoc_STRVAR(readinto_doc, ...@@ -387,7 +387,7 @@ PyDoc_STRVAR(readinto_doc,
"is set not to block as has no data to read."); "is set not to block as has no data to read.");
static PyObject * static PyObject *
bytesio_readinto(BytesIOObject *self, PyObject *buffer) bytesio_readinto(bytesio *self, PyObject *buffer)
{ {
void *raw_buffer; void *raw_buffer;
Py_ssize_t len; Py_ssize_t len;
...@@ -415,7 +415,7 @@ PyDoc_STRVAR(truncate_doc, ...@@ -415,7 +415,7 @@ PyDoc_STRVAR(truncate_doc,
"Returns the new size. Imply an absolute seek to the position size."); "Returns the new size. Imply an absolute seek to the position size.");
static PyObject * static PyObject *
bytesio_truncate(BytesIOObject *self, PyObject *args) bytesio_truncate(bytesio *self, PyObject *args)
{ {
Py_ssize_t size; Py_ssize_t size;
PyObject *arg = Py_None; PyObject *arg = Py_None;
...@@ -457,7 +457,7 @@ bytesio_truncate(BytesIOObject *self, PyObject *args) ...@@ -457,7 +457,7 @@ bytesio_truncate(BytesIOObject *self, PyObject *args)
} }
static PyObject * static PyObject *
bytesio_iternext(BytesIOObject *self) bytesio_iternext(bytesio *self)
{ {
char *next; char *next;
Py_ssize_t n; Py_ssize_t n;
...@@ -482,7 +482,7 @@ PyDoc_STRVAR(seek_doc, ...@@ -482,7 +482,7 @@ PyDoc_STRVAR(seek_doc,
"Returns the new absolute position."); "Returns the new absolute position.");
static PyObject * static PyObject *
bytesio_seek(BytesIOObject *self, PyObject *args) bytesio_seek(bytesio *self, PyObject *args)
{ {
Py_ssize_t pos; Py_ssize_t pos;
int mode = 0; int mode = 0;
...@@ -536,7 +536,7 @@ PyDoc_STRVAR(write_doc, ...@@ -536,7 +536,7 @@ PyDoc_STRVAR(write_doc,
"Return the number of bytes written."); "Return the number of bytes written.");
static PyObject * static PyObject *
bytesio_write(BytesIOObject *self, PyObject *obj) bytesio_write(bytesio *self, PyObject *obj)
{ {
Py_ssize_t n = 0; Py_ssize_t n = 0;
Py_buffer buf; Py_buffer buf;
...@@ -564,7 +564,7 @@ PyDoc_STRVAR(writelines_doc, ...@@ -564,7 +564,7 @@ PyDoc_STRVAR(writelines_doc,
"each string."); "each string.");
static PyObject * static PyObject *
bytesio_writelines(BytesIOObject *self, PyObject *v) bytesio_writelines(bytesio *self, PyObject *v)
{ {
PyObject *it, *item; PyObject *it, *item;
PyObject *ret; PyObject *ret;
...@@ -597,7 +597,7 @@ PyDoc_STRVAR(close_doc, ...@@ -597,7 +597,7 @@ PyDoc_STRVAR(close_doc,
"close() -> None. Disable all I/O operations."); "close() -> None. Disable all I/O operations.");
static PyObject * static PyObject *
bytesio_close(BytesIOObject *self) bytesio_close(bytesio *self)
{ {
if (self->buf != NULL) { if (self->buf != NULL) {
PyMem_Free(self->buf); PyMem_Free(self->buf);
...@@ -607,7 +607,7 @@ bytesio_close(BytesIOObject *self) ...@@ -607,7 +607,7 @@ bytesio_close(BytesIOObject *self)
} }
static void static void
bytesio_dealloc(BytesIOObject *self) bytesio_dealloc(bytesio *self)
{ {
if (self->buf != NULL) { if (self->buf != NULL) {
PyMem_Free(self->buf); PyMem_Free(self->buf);
...@@ -620,10 +620,10 @@ bytesio_dealloc(BytesIOObject *self) ...@@ -620,10 +620,10 @@ bytesio_dealloc(BytesIOObject *self)
static PyObject * static PyObject *
bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
BytesIOObject *self; bytesio *self;
assert(type != NULL && type->tp_alloc != NULL); assert(type != NULL && type->tp_alloc != NULL);
self = (BytesIOObject *)type->tp_alloc(type, 0); self = (bytesio *)type->tp_alloc(type, 0);
if (self == NULL) if (self == NULL)
return NULL; return NULL;
...@@ -640,7 +640,7 @@ bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ...@@ -640,7 +640,7 @@ bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
} }
static int static int
bytesio_init(BytesIOObject *self, PyObject *args, PyObject *kwds) bytesio_init(bytesio *self, PyObject *args, PyObject *kwds)
{ {
PyObject *initvalue = NULL; PyObject *initvalue = NULL;
...@@ -664,7 +664,7 @@ bytesio_init(BytesIOObject *self, PyObject *args, PyObject *kwds) ...@@ -664,7 +664,7 @@ bytesio_init(BytesIOObject *self, PyObject *args, PyObject *kwds)
} }
static int 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->dict);
Py_VISIT(self->weakreflist); Py_VISIT(self->weakreflist);
...@@ -672,7 +672,7 @@ bytesio_traverse(BytesIOObject *self, visitproc visit, void *arg) ...@@ -672,7 +672,7 @@ bytesio_traverse(BytesIOObject *self, visitproc visit, void *arg)
} }
static int static int
bytesio_clear(BytesIOObject *self) bytesio_clear(bytesio *self)
{ {
Py_CLEAR(self->dict); Py_CLEAR(self->dict);
if (self->weakreflist != NULL) if (self->weakreflist != NULL)
...@@ -717,7 +717,7 @@ PyDoc_STRVAR(bytesio_doc, ...@@ -717,7 +717,7 @@ PyDoc_STRVAR(bytesio_doc,
PyTypeObject PyBytesIO_Type = { PyTypeObject PyBytesIO_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"_io.BytesIO", /*tp_name*/ "_io.BytesIO", /*tp_name*/
sizeof(BytesIOObject), /*tp_basicsize*/ sizeof(bytesio), /*tp_basicsize*/
0, /*tp_itemsize*/ 0, /*tp_itemsize*/
(destructor)bytesio_dealloc, /*tp_dealloc*/ (destructor)bytesio_dealloc, /*tp_dealloc*/
0, /*tp_print*/ 0, /*tp_print*/
...@@ -740,7 +740,7 @@ PyTypeObject PyBytesIO_Type = { ...@@ -740,7 +740,7 @@ PyTypeObject PyBytesIO_Type = {
(traverseproc)bytesio_traverse, /*tp_traverse*/ (traverseproc)bytesio_traverse, /*tp_traverse*/
(inquiry)bytesio_clear, /*tp_clear*/ (inquiry)bytesio_clear, /*tp_clear*/
0, /*tp_richcompare*/ 0, /*tp_richcompare*/
offsetof(BytesIOObject, weakreflist), /*tp_weaklistoffset*/ offsetof(bytesio, weakreflist), /*tp_weaklistoffset*/
PyObject_SelfIter, /*tp_iter*/ PyObject_SelfIter, /*tp_iter*/
(iternextfunc)bytesio_iternext, /*tp_iternext*/ (iternextfunc)bytesio_iternext, /*tp_iternext*/
bytesio_methods, /*tp_methods*/ bytesio_methods, /*tp_methods*/
...@@ -750,7 +750,7 @@ PyTypeObject PyBytesIO_Type = { ...@@ -750,7 +750,7 @@ PyTypeObject PyBytesIO_Type = {
0, /*tp_dict*/ 0, /*tp_dict*/
0, /*tp_descr_get*/ 0, /*tp_descr_get*/
0, /*tp_descr_set*/ 0, /*tp_descr_set*/
offsetof(BytesIOObject, dict), /*tp_dictoffset*/ offsetof(bytesio, dict), /*tp_dictoffset*/
(initproc)bytesio_init, /*tp_init*/ (initproc)bytesio_init, /*tp_init*/
0, /*tp_alloc*/ 0, /*tp_alloc*/
bytesio_new, /*tp_new*/ bytesio_new, /*tp_new*/
......
...@@ -51,7 +51,7 @@ typedef struct { ...@@ -51,7 +51,7 @@ typedef struct {
int closefd : 1; int closefd : 1;
PyObject *weakreflist; PyObject *weakreflist;
PyObject *dict; PyObject *dict;
} PyFileIOObject; } fileio;
PyTypeObject PyFileIO_Type; PyTypeObject PyFileIO_Type;
...@@ -60,7 +60,7 @@ PyTypeObject PyFileIO_Type; ...@@ -60,7 +60,7 @@ PyTypeObject PyFileIO_Type;
int int
_PyFileIO_closed(PyObject *self) _PyFileIO_closed(PyObject *self)
{ {
return ((PyFileIOObject *)self)->fd < 0; return ((fileio *)self)->fd < 0;
} }
static PyObject * static PyObject *
...@@ -70,7 +70,7 @@ static PyObject *portable_lseek(int fd, PyObject *posobj, int whence); ...@@ -70,7 +70,7 @@ static PyObject *portable_lseek(int fd, PyObject *posobj, int whence);
/* Returns 0 on success, -1 with exception set on failure. */ /* Returns 0 on success, -1 with exception set on failure. */
static int static int
internal_close(PyFileIOObject *self) internal_close(fileio *self)
{ {
int err = 0; int err = 0;
int save_errno = 0; int save_errno = 0;
...@@ -98,7 +98,7 @@ internal_close(PyFileIOObject *self) ...@@ -98,7 +98,7 @@ internal_close(PyFileIOObject *self)
} }
static PyObject * static PyObject *
fileio_close(PyFileIOObject *self) fileio_close(fileio *self)
{ {
if (!self->closefd) { if (!self->closefd) {
self->fd = -1; self->fd = -1;
...@@ -115,11 +115,11 @@ fileio_close(PyFileIOObject *self) ...@@ -115,11 +115,11 @@ fileio_close(PyFileIOObject *self)
static PyObject * static PyObject *
fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
PyFileIOObject *self; fileio *self;
assert(type != NULL && type->tp_alloc != NULL); assert(type != NULL && type->tp_alloc != NULL);
self = (PyFileIOObject *) type->tp_alloc(type, 0); self = (fileio *) type->tp_alloc(type, 0);
if (self != NULL) { if (self != NULL) {
self->fd = -1; self->fd = -1;
self->readable = 0; self->readable = 0;
...@@ -137,7 +137,7 @@ fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ...@@ -137,7 +137,7 @@ fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
directories, so we need a check. */ directories, so we need a check. */
static int static int
dircheck(PyFileIOObject* self, const char *name) dircheck(fileio* self, const char *name)
{ {
#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
struct stat buf; struct stat buf;
...@@ -181,7 +181,7 @@ check_fd(int fd) ...@@ -181,7 +181,7 @@ check_fd(int fd)
static int static int
fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
{ {
PyFileIOObject *self = (PyFileIOObject *) oself; fileio *self = (fileio *) oself;
static char *kwlist[] = {"file", "mode", "closefd", NULL}; static char *kwlist[] = {"file", "mode", "closefd", NULL};
const char *name = NULL; const char *name = NULL;
PyObject *nameobj, *stringobj = NULL; PyObject *nameobj, *stringobj = NULL;
...@@ -380,21 +380,21 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) ...@@ -380,21 +380,21 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
} }
static int static int
fileio_traverse(PyFileIOObject *self, visitproc visit, void *arg) fileio_traverse(fileio *self, visitproc visit, void *arg)
{ {
Py_VISIT(self->dict); Py_VISIT(self->dict);
return 0; return 0;
} }
static int static int
fileio_clear(PyFileIOObject *self) fileio_clear(fileio *self)
{ {
Py_CLEAR(self->dict); Py_CLEAR(self->dict);
return 0; return 0;
} }
static void static void
fileio_dealloc(PyFileIOObject *self) fileio_dealloc(fileio *self)
{ {
if (_PyIOBase_finalize((PyObject *) self) < 0) if (_PyIOBase_finalize((PyObject *) self) < 0)
return; return;
...@@ -420,7 +420,7 @@ err_mode(char *action) ...@@ -420,7 +420,7 @@ err_mode(char *action)
} }
static PyObject * static PyObject *
fileio_fileno(PyFileIOObject *self) fileio_fileno(fileio *self)
{ {
if (self->fd < 0) if (self->fd < 0)
return err_closed(); return err_closed();
...@@ -428,7 +428,7 @@ fileio_fileno(PyFileIOObject *self) ...@@ -428,7 +428,7 @@ fileio_fileno(PyFileIOObject *self)
} }
static PyObject * static PyObject *
fileio_readable(PyFileIOObject *self) fileio_readable(fileio *self)
{ {
if (self->fd < 0) if (self->fd < 0)
return err_closed(); return err_closed();
...@@ -436,7 +436,7 @@ fileio_readable(PyFileIOObject *self) ...@@ -436,7 +436,7 @@ fileio_readable(PyFileIOObject *self)
} }
static PyObject * static PyObject *
fileio_writable(PyFileIOObject *self) fileio_writable(fileio *self)
{ {
if (self->fd < 0) if (self->fd < 0)
return err_closed(); return err_closed();
...@@ -444,7 +444,7 @@ fileio_writable(PyFileIOObject *self) ...@@ -444,7 +444,7 @@ fileio_writable(PyFileIOObject *self)
} }
static PyObject * static PyObject *
fileio_seekable(PyFileIOObject *self) fileio_seekable(fileio *self)
{ {
if (self->fd < 0) if (self->fd < 0)
return err_closed(); return err_closed();
...@@ -462,7 +462,7 @@ fileio_seekable(PyFileIOObject *self) ...@@ -462,7 +462,7 @@ fileio_seekable(PyFileIOObject *self)
} }
static PyObject * static PyObject *
fileio_readinto(PyFileIOObject *self, PyObject *args) fileio_readinto(fileio *self, PyObject *args)
{ {
Py_buffer pbuf; Py_buffer pbuf;
Py_ssize_t n; Py_ssize_t n;
...@@ -494,7 +494,7 @@ fileio_readinto(PyFileIOObject *self, PyObject *args) ...@@ -494,7 +494,7 @@ fileio_readinto(PyFileIOObject *self, PyObject *args)
} }
static size_t static size_t
new_buffersize(PyFileIOObject *self, size_t currentsize) new_buffersize(fileio *self, size_t currentsize)
{ {
#ifdef HAVE_FSTAT #ifdef HAVE_FSTAT
off_t pos, end; off_t pos, end;
...@@ -524,7 +524,7 @@ new_buffersize(PyFileIOObject *self, size_t currentsize) ...@@ -524,7 +524,7 @@ new_buffersize(PyFileIOObject *self, size_t currentsize)
} }
static PyObject * static PyObject *
fileio_readall(PyFileIOObject *self) fileio_readall(fileio *self)
{ {
PyObject *result; PyObject *result;
Py_ssize_t total = 0; Py_ssize_t total = 0;
...@@ -590,7 +590,7 @@ fileio_readall(PyFileIOObject *self) ...@@ -590,7 +590,7 @@ fileio_readall(PyFileIOObject *self)
} }
static PyObject * static PyObject *
fileio_read(PyFileIOObject *self, PyObject *args) fileio_read(fileio *self, PyObject *args)
{ {
char *ptr; char *ptr;
Py_ssize_t n; Py_ssize_t n;
...@@ -641,7 +641,7 @@ fileio_read(PyFileIOObject *self, PyObject *args) ...@@ -641,7 +641,7 @@ fileio_read(PyFileIOObject *self, PyObject *args)
} }
static PyObject * static PyObject *
fileio_write(PyFileIOObject *self, PyObject *args) fileio_write(fileio *self, PyObject *args)
{ {
Py_buffer pbuf; Py_buffer pbuf;
Py_ssize_t n; Py_ssize_t n;
...@@ -734,7 +734,7 @@ portable_lseek(int fd, PyObject *posobj, int whence) ...@@ -734,7 +734,7 @@ portable_lseek(int fd, PyObject *posobj, int whence)
} }
static PyObject * static PyObject *
fileio_seek(PyFileIOObject *self, PyObject *args) fileio_seek(fileio *self, PyObject *args)
{ {
PyObject *posobj; PyObject *posobj;
int whence = 0; int whence = 0;
...@@ -749,7 +749,7 @@ fileio_seek(PyFileIOObject *self, PyObject *args) ...@@ -749,7 +749,7 @@ fileio_seek(PyFileIOObject *self, PyObject *args)
} }
static PyObject * static PyObject *
fileio_tell(PyFileIOObject *self, PyObject *args) fileio_tell(fileio *self, PyObject *args)
{ {
if (self->fd < 0) if (self->fd < 0)
return err_closed(); return err_closed();
...@@ -759,7 +759,7 @@ fileio_tell(PyFileIOObject *self, PyObject *args) ...@@ -759,7 +759,7 @@ fileio_tell(PyFileIOObject *self, PyObject *args)
#ifdef HAVE_FTRUNCATE #ifdef HAVE_FTRUNCATE
static PyObject * static PyObject *
fileio_truncate(PyFileIOObject *self, PyObject *args) fileio_truncate(fileio *self, PyObject *args)
{ {
PyObject *posobj = NULL; PyObject *posobj = NULL;
Py_off_t pos; Py_off_t pos;
...@@ -831,7 +831,7 @@ fileio_truncate(PyFileIOObject *self, PyObject *args) ...@@ -831,7 +831,7 @@ fileio_truncate(PyFileIOObject *self, PyObject *args)
#endif #endif
static char * static char *
mode_string(PyFileIOObject *self) mode_string(fileio *self)
{ {
if (self->readable) { if (self->readable) {
if (self->writable) if (self->writable)
...@@ -844,7 +844,7 @@ mode_string(PyFileIOObject *self) ...@@ -844,7 +844,7 @@ mode_string(PyFileIOObject *self)
} }
static PyObject * static PyObject *
fileio_repr(PyFileIOObject *self) fileio_repr(fileio *self)
{ {
PyObject *nameobj, *res; PyObject *nameobj, *res;
...@@ -869,7 +869,7 @@ fileio_repr(PyFileIOObject *self) ...@@ -869,7 +869,7 @@ fileio_repr(PyFileIOObject *self)
} }
static PyObject * static PyObject *
fileio_isatty(PyFileIOObject *self) fileio_isatty(fileio *self)
{ {
long res; long res;
...@@ -980,19 +980,19 @@ static PyMethodDef fileio_methods[] = { ...@@ -980,19 +980,19 @@ static PyMethodDef fileio_methods[] = {
/* 'closed' and 'mode' are attributes for backwards compatibility reasons. */ /* 'closed' and 'mode' are attributes for backwards compatibility reasons. */
static PyObject * static PyObject *
get_closed(PyFileIOObject *self, void *closure) get_closed(fileio *self, void *closure)
{ {
return PyBool_FromLong((long)(self->fd < 0)); return PyBool_FromLong((long)(self->fd < 0));
} }
static PyObject * static PyObject *
get_closefd(PyFileIOObject *self, void *closure) get_closefd(fileio *self, void *closure)
{ {
return PyBool_FromLong((long)(self->closefd)); return PyBool_FromLong((long)(self->closefd));
} }
static PyObject * static PyObject *
get_mode(PyFileIOObject *self, void *closure) get_mode(fileio *self, void *closure)
{ {
return PyUnicode_FromString(mode_string(self)); return PyUnicode_FromString(mode_string(self));
} }
...@@ -1008,7 +1008,7 @@ static PyGetSetDef fileio_getsetlist[] = { ...@@ -1008,7 +1008,7 @@ static PyGetSetDef fileio_getsetlist[] = {
PyTypeObject PyFileIO_Type = { PyTypeObject PyFileIO_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"_io.FileIO", "_io.FileIO",
sizeof(PyFileIOObject), sizeof(fileio),
0, 0,
(destructor)fileio_dealloc, /* tp_dealloc */ (destructor)fileio_dealloc, /* tp_dealloc */
0, /* tp_print */ 0, /* tp_print */
...@@ -1031,7 +1031,7 @@ PyTypeObject PyFileIO_Type = { ...@@ -1031,7 +1031,7 @@ PyTypeObject PyFileIO_Type = {
(traverseproc)fileio_traverse, /* tp_traverse */ (traverseproc)fileio_traverse, /* tp_traverse */
(inquiry)fileio_clear, /* tp_clear */ (inquiry)fileio_clear, /* tp_clear */
0, /* tp_richcompare */ 0, /* tp_richcompare */
offsetof(PyFileIOObject, weakreflist), /* tp_weaklistoffset */ offsetof(fileio, weakreflist), /* tp_weaklistoffset */
0, /* tp_iter */ 0, /* tp_iter */
0, /* tp_iternext */ 0, /* tp_iternext */
fileio_methods, /* tp_methods */ fileio_methods, /* tp_methods */
...@@ -1041,7 +1041,7 @@ PyTypeObject PyFileIO_Type = { ...@@ -1041,7 +1041,7 @@ PyTypeObject PyFileIO_Type = {
0, /* tp_dict */ 0, /* tp_dict */
0, /* tp_descr_get */ 0, /* tp_descr_get */
0, /* tp_descr_set */ 0, /* tp_descr_set */
offsetof(PyFileIOObject, dict), /* tp_dictoffset */ offsetof(fileio, dict), /* tp_dictoffset */
fileio_init, /* tp_init */ fileio_init, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */ PyType_GenericAlloc, /* tp_alloc */
fileio_new, /* tp_new */ fileio_new, /* tp_new */
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ typedef struct { ...@@ -24,7 +24,7 @@ typedef struct {
PyObject *dict; PyObject *dict;
PyObject *weakreflist; PyObject *weakreflist;
} StringIOObject; } stringio;
#define CHECK_INITIALIZED(self) \ #define CHECK_INITIALIZED(self) \
if (self->ok <= 0) { \ if (self->ok <= 0) { \
...@@ -51,7 +51,7 @@ PyDoc_STRVAR(stringio_doc, ...@@ -51,7 +51,7 @@ PyDoc_STRVAR(stringio_doc,
buffer of StringIO objects. The caller should ensure that the 'size' buffer of StringIO objects. The caller should ensure that the 'size'
argument is non-negative. Returns 0 on success, -1 otherwise. */ argument is non-negative. Returns 0 on success, -1 otherwise. */
static int 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 /* Here, unsigned types are used to avoid dealing with signed integer
overflow, which is undefined in C. */ overflow, which is undefined in C. */
...@@ -106,7 +106,7 @@ resize_buffer(StringIOObject *self, size_t size) ...@@ -106,7 +106,7 @@ resize_buffer(StringIOObject *self, size_t size)
/* Internal routine for writing a whole PyUnicode object to the buffer of a /* Internal routine for writing a whole PyUnicode object to the buffer of a
StringIO object. Returns 0 on success, or -1 on error. */ StringIO object. Returns 0 on success, or -1 on error. */
static Py_ssize_t static Py_ssize_t
write_str(StringIOObject *self, PyObject *obj) write_str(stringio *self, PyObject *obj)
{ {
Py_UNICODE *str; Py_UNICODE *str;
Py_ssize_t len; Py_ssize_t len;
...@@ -186,7 +186,7 @@ PyDoc_STRVAR(stringio_getvalue_doc, ...@@ -186,7 +186,7 @@ PyDoc_STRVAR(stringio_getvalue_doc,
"Retrieve the entire contents of the object."); "Retrieve the entire contents of the object.");
static PyObject * static PyObject *
stringio_getvalue(StringIOObject *self) stringio_getvalue(stringio *self)
{ {
CHECK_INITIALIZED(self); CHECK_INITIALIZED(self);
CHECK_CLOSED(self); CHECK_CLOSED(self);
...@@ -197,7 +197,7 @@ PyDoc_STRVAR(stringio_tell_doc, ...@@ -197,7 +197,7 @@ PyDoc_STRVAR(stringio_tell_doc,
"Tell the current file position."); "Tell the current file position.");
static PyObject * static PyObject *
stringio_tell(StringIOObject *self) stringio_tell(stringio *self)
{ {
CHECK_INITIALIZED(self); CHECK_INITIALIZED(self);
CHECK_CLOSED(self); CHECK_CLOSED(self);
...@@ -211,7 +211,7 @@ PyDoc_STRVAR(stringio_read_doc, ...@@ -211,7 +211,7 @@ PyDoc_STRVAR(stringio_read_doc,
"is reached. Return an empty string at EOF.\n"); "is reached. Return an empty string at EOF.\n");
static PyObject * static PyObject *
stringio_read(StringIOObject *self, PyObject *args) stringio_read(stringio *self, PyObject *args)
{ {
Py_ssize_t size, n; Py_ssize_t size, n;
Py_UNICODE *output; Py_UNICODE *output;
...@@ -252,7 +252,7 @@ stringio_read(StringIOObject *self, PyObject *args) ...@@ -252,7 +252,7 @@ stringio_read(StringIOObject *self, PyObject *args)
/* Internal helper, used by stringio_readline and stringio_iternext */ /* Internal helper, used by stringio_readline and stringio_iternext */
static PyObject * 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_UNICODE *start, *end, old_char;
Py_ssize_t len, consumed; Py_ssize_t len, consumed;
...@@ -286,7 +286,7 @@ PyDoc_STRVAR(stringio_readline_doc, ...@@ -286,7 +286,7 @@ PyDoc_STRVAR(stringio_readline_doc,
"Returns an empty string if EOF is hit immediately.\n"); "Returns an empty string if EOF is hit immediately.\n");
static PyObject * static PyObject *
stringio_readline(StringIOObject *self, PyObject *args) stringio_readline(stringio *self, PyObject *args)
{ {
PyObject *arg = Py_None; PyObject *arg = Py_None;
Py_ssize_t limit = -1; Py_ssize_t limit = -1;
...@@ -310,7 +310,7 @@ stringio_readline(StringIOObject *self, PyObject *args) ...@@ -310,7 +310,7 @@ stringio_readline(StringIOObject *self, PyObject *args)
} }
static PyObject * static PyObject *
stringio_iternext(StringIOObject *self) stringio_iternext(stringio *self)
{ {
PyObject *line; PyObject *line;
...@@ -354,7 +354,7 @@ PyDoc_STRVAR(stringio_truncate_doc, ...@@ -354,7 +354,7 @@ PyDoc_STRVAR(stringio_truncate_doc,
"Returns the new absolute position.\n"); "Returns the new absolute position.\n");
static PyObject * static PyObject *
stringio_truncate(StringIOObject *self, PyObject *args) stringio_truncate(stringio *self, PyObject *args)
{ {
Py_ssize_t size; Py_ssize_t size;
PyObject *arg = Py_None; PyObject *arg = Py_None;
...@@ -405,7 +405,7 @@ PyDoc_STRVAR(stringio_seek_doc, ...@@ -405,7 +405,7 @@ PyDoc_STRVAR(stringio_seek_doc,
"Returns the new absolute position.\n"); "Returns the new absolute position.\n");
static PyObject * static PyObject *
stringio_seek(StringIOObject *self, PyObject *args) stringio_seek(stringio *self, PyObject *args)
{ {
Py_ssize_t pos; Py_ssize_t pos;
int mode = 0; int mode = 0;
...@@ -453,7 +453,7 @@ PyDoc_STRVAR(stringio_write_doc, ...@@ -453,7 +453,7 @@ PyDoc_STRVAR(stringio_write_doc,
"the length of the string.\n"); "the length of the string.\n");
static PyObject * static PyObject *
stringio_write(StringIOObject *self, PyObject *obj) stringio_write(stringio *self, PyObject *obj)
{ {
Py_ssize_t size; Py_ssize_t size;
...@@ -479,7 +479,7 @@ PyDoc_STRVAR(stringio_close_doc, ...@@ -479,7 +479,7 @@ PyDoc_STRVAR(stringio_close_doc,
"This method has no effect if the file is already closed.\n"); "This method has no effect if the file is already closed.\n");
static PyObject * static PyObject *
stringio_close(StringIOObject *self) stringio_close(stringio *self)
{ {
self->closed = 1; self->closed = 1;
/* Free up some memory */ /* Free up some memory */
...@@ -492,21 +492,21 @@ stringio_close(StringIOObject *self) ...@@ -492,21 +492,21 @@ stringio_close(StringIOObject *self)
} }
static int static int
stringio_traverse(StringIOObject *self, visitproc visit, void *arg) stringio_traverse(stringio *self, visitproc visit, void *arg)
{ {
Py_VISIT(self->dict); Py_VISIT(self->dict);
return 0; return 0;
} }
static int static int
stringio_clear(StringIOObject *self) stringio_clear(stringio *self)
{ {
Py_CLEAR(self->dict); Py_CLEAR(self->dict);
return 0; return 0;
} }
static void static void
stringio_dealloc(StringIOObject *self) stringio_dealloc(stringio *self)
{ {
_PyObject_GC_UNTRACK(self); _PyObject_GC_UNTRACK(self);
Py_CLEAR(self->readnl); Py_CLEAR(self->readnl);
...@@ -522,10 +522,10 @@ stringio_dealloc(StringIOObject *self) ...@@ -522,10 +522,10 @@ stringio_dealloc(StringIOObject *self)
static PyObject * static PyObject *
stringio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) stringio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
StringIOObject *self; stringio *self;
assert(type != NULL && type->tp_alloc != NULL); assert(type != NULL && type->tp_alloc != NULL);
self = (StringIOObject *)type->tp_alloc(type, 0); self = (stringio *)type->tp_alloc(type, 0);
if (self == NULL) if (self == NULL)
return NULL; return NULL;
...@@ -542,7 +542,7 @@ stringio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ...@@ -542,7 +542,7 @@ stringio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
} }
static int static int
stringio_init(StringIOObject *self, PyObject *args, PyObject *kwds) stringio_init(stringio *self, PyObject *args, PyObject *kwds)
{ {
char *kwlist[] = {"initial_value", "newline", NULL}; char *kwlist[] = {"initial_value", "newline", NULL};
PyObject *value = NULL; PyObject *value = NULL;
...@@ -625,28 +625,28 @@ stringio_init(StringIOObject *self, PyObject *args, PyObject *kwds) ...@@ -625,28 +625,28 @@ stringio_init(StringIOObject *self, PyObject *args, PyObject *kwds)
/* Properties and pseudo-properties */ /* Properties and pseudo-properties */
static PyObject * static PyObject *
stringio_seekable(StringIOObject *self, PyObject *args) stringio_seekable(stringio *self, PyObject *args)
{ {
CHECK_INITIALIZED(self); CHECK_INITIALIZED(self);
Py_RETURN_TRUE; Py_RETURN_TRUE;
} }
static PyObject * static PyObject *
stringio_readable(StringIOObject *self, PyObject *args) stringio_readable(stringio *self, PyObject *args)
{ {
CHECK_INITIALIZED(self); CHECK_INITIALIZED(self);
Py_RETURN_TRUE; Py_RETURN_TRUE;
} }
static PyObject * static PyObject *
stringio_writable(StringIOObject *self, PyObject *args) stringio_writable(stringio *self, PyObject *args)
{ {
CHECK_INITIALIZED(self); CHECK_INITIALIZED(self);
Py_RETURN_TRUE; Py_RETURN_TRUE;
} }
static PyObject * static PyObject *
stringio_buffer(StringIOObject *self, void *context) stringio_buffer(stringio *self, void *context)
{ {
PyErr_SetString(IO_STATE->unsupported_operation, PyErr_SetString(IO_STATE->unsupported_operation,
"buffer attribute is unsupported on type StringIO"); "buffer attribute is unsupported on type StringIO");
...@@ -654,14 +654,14 @@ stringio_buffer(StringIOObject *self, void *context) ...@@ -654,14 +654,14 @@ stringio_buffer(StringIOObject *self, void *context)
} }
static PyObject * static PyObject *
stringio_closed(StringIOObject *self, void *context) stringio_closed(stringio *self, void *context)
{ {
CHECK_INITIALIZED(self); CHECK_INITIALIZED(self);
return PyBool_FromLong(self->closed); return PyBool_FromLong(self->closed);
} }
static PyObject * static PyObject *
stringio_line_buffering(StringIOObject *self, void *context) stringio_line_buffering(stringio *self, void *context)
{ {
CHECK_INITIALIZED(self); CHECK_INITIALIZED(self);
CHECK_CLOSED(self); CHECK_CLOSED(self);
...@@ -669,7 +669,7 @@ stringio_line_buffering(StringIOObject *self, void *context) ...@@ -669,7 +669,7 @@ stringio_line_buffering(StringIOObject *self, void *context)
} }
static PyObject * static PyObject *
stringio_newlines(StringIOObject *self, void *context) stringio_newlines(stringio *self, void *context)
{ {
CHECK_INITIALIZED(self); CHECK_INITIALIZED(self);
CHECK_CLOSED(self); CHECK_CLOSED(self);
...@@ -711,7 +711,7 @@ static PyGetSetDef stringio_getset[] = { ...@@ -711,7 +711,7 @@ static PyGetSetDef stringio_getset[] = {
PyTypeObject PyStringIO_Type = { PyTypeObject PyStringIO_Type = {
PyVarObject_HEAD_INIT(NULL, 0) PyVarObject_HEAD_INIT(NULL, 0)
"_io.StringIO", /*tp_name*/ "_io.StringIO", /*tp_name*/
sizeof(StringIOObject), /*tp_basicsize*/ sizeof(stringio), /*tp_basicsize*/
0, /*tp_itemsize*/ 0, /*tp_itemsize*/
(destructor)stringio_dealloc, /*tp_dealloc*/ (destructor)stringio_dealloc, /*tp_dealloc*/
0, /*tp_print*/ 0, /*tp_print*/
...@@ -734,7 +734,7 @@ PyTypeObject PyStringIO_Type = { ...@@ -734,7 +734,7 @@ PyTypeObject PyStringIO_Type = {
(traverseproc)stringio_traverse, /*tp_traverse*/ (traverseproc)stringio_traverse, /*tp_traverse*/
(inquiry)stringio_clear, /*tp_clear*/ (inquiry)stringio_clear, /*tp_clear*/
0, /*tp_richcompare*/ 0, /*tp_richcompare*/
offsetof(StringIOObject, weakreflist), /*tp_weaklistoffset*/ offsetof(stringio, weakreflist), /*tp_weaklistoffset*/
0, /*tp_iter*/ 0, /*tp_iter*/
(iternextfunc)stringio_iternext, /*tp_iternext*/ (iternextfunc)stringio_iternext, /*tp_iternext*/
stringio_methods, /*tp_methods*/ stringio_methods, /*tp_methods*/
...@@ -744,7 +744,7 @@ PyTypeObject PyStringIO_Type = { ...@@ -744,7 +744,7 @@ PyTypeObject PyStringIO_Type = {
0, /*tp_dict*/ 0, /*tp_dict*/
0, /*tp_descr_get*/ 0, /*tp_descr_get*/
0, /*tp_descr_set*/ 0, /*tp_descr_set*/
offsetof(StringIOObject, dict), /*tp_dictoffset*/ offsetof(stringio, dict), /*tp_dictoffset*/
(initproc)stringio_init, /*tp_init*/ (initproc)stringio_init, /*tp_init*/
0, /*tp_alloc*/ 0, /*tp_alloc*/
stringio_new, /*tp_new*/ stringio_new, /*tp_new*/
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment