Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
680bf1af
Commit
680bf1af
authored
Jun 12, 2009
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move to a naming scheme with all lowercase and underscores
parent
2c3ac6b8
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
660 additions
and
665 deletions
+660
-665
Modules/_io/_iomodule.c
Modules/_io/_iomodule.c
+4
-4
Modules/_io/_iomodule.h
Modules/_io/_iomodule.h
+4
-4
Modules/_io/bufferedio.c
Modules/_io/bufferedio.c
+301
-303
Modules/_io/bytesio.c
Modules/_io/bytesio.c
+30
-30
Modules/_io/fileio.c
Modules/_io/fileio.c
+32
-32
Modules/_io/iobase.c
Modules/_io/iobase.c
+91
-91
Modules/_io/stringio.c
Modules/_io/stringio.c
+29
-29
Modules/_io/textio.c
Modules/_io/textio.c
+169
-172
No files found.
Modules/_io/_iomodule.c
View file @
680bf1af
...
...
@@ -94,7 +94,7 @@ PyDoc_STRVAR(module_doc,
*/
static
int
BlockingIOE
rror_init
(
PyBlockingIOErrorObject
*
self
,
PyObject
*
args
,
blockingioe
rror_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
BlockingIOE
rror_members
[]
=
{
static
PyMemberDef
blockingioe
rror_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 */
BlockingIOE
rror_members
,
/* tp_members */
blockingioe
rror_members
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
(
initproc
)
BlockingIOE
rror_init
,
/* tp_init */
(
initproc
)
blockingioe
rror_init
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_new */
};
...
...
Modules/_io/_iomodule.h
View file @
680bf1af
...
...
@@ -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_check
R
eadable
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
_PyIOBase_check
W
ritable
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
_PyIOBase_check
S
eekable
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
_PyIOBase_check
C
losed
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
_PyIOBase_check
_r
eadable
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
_PyIOBase_check
_w
ritable
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
_PyIOBase_check
_s
eekable
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
_PyIOBase_check
_c
losed
(
PyObject
*
self
,
PyObject
*
args
);
/* Helper for finalization.
This function will revive an object ready to be deallocated and try to
...
...
Modules/_io/bufferedio.c
View file @
680bf1af
This diff is collapsed.
Click to expand it.
Modules/_io/bytesio.c
View file @
680bf1af
...
...
@@ -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*/
...
...
Modules/_io/fileio.c
View file @
680bf1af
...
...
@@ -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 */
...
...
Modules/_io/iobase.c
View file @
680bf1af
This diff is collapsed.
Click to expand it.
Modules/_io/stringio.c
View file @
680bf1af
...
...
@@ -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*/
...
...
Modules/_io/textio.c
View file @
680bf1af
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment