mirror of https://github.com/python/cpython
move to a naming scheme with all lowercase and underscores
This commit is contained in:
parent
2c3ac6b875
commit
680bf1afe8
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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*/
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue