summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-10 13:08:43 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-10 13:08:43 (GMT)
commit3d2279f9a8c1e896dad4f6d2a732d08fadf6922b (patch)
treee578ca345e9d06173857edad507ebbf272bd2e2b /Modules/_io
parent7e7a3dba5fd4262269f713dfe21ba7e4746fc2dd (diff)
downloadcpython-3d2279f9a8c1e896dad4f6d2a732d08fadf6922b.zip
cpython-3d2279f9a8c1e896dad4f6d2a732d08fadf6922b.tar.gz
cpython-3d2279f9a8c1e896dad4f6d2a732d08fadf6922b.tar.bz2
Issue #21859: Corrected FileIO docstrings.
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/fileio.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 23ca31d..95bcb77 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -267,7 +267,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
if (fd < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,
- "Negative filedescriptor");
+ "negative file descriptor");
return -1;
}
PyErr_Clear();
@@ -1094,10 +1094,10 @@ fileio_getstate(fileio *self)
PyDoc_STRVAR(fileio_doc,
"file(name: str[, mode: str][, opener: None]) -> file IO object\n"
"\n"
-"Open a file. The mode can be 'r', 'w', 'x' or 'a' for reading (default),\n"
+"Open a file. The mode can be 'r' (default), 'w', 'x' or 'a' for reading,\n"
"writing, exclusive creation or appending. The file will be created if it\n"
"doesn't exist when opened for writing or appending; it will be truncated\n"
-"when opened for writing. A `FileExistsError` will be raised if it already\n"
+"when opened for writing. A FileExistsError will be raised if it already\n"
"exists when opened for creating. Opening a file for creating implies\n"
"writing so this mode behaves in a similar way to 'w'.Add a '+' to the mode\n"
"to allow simultaneous reading and writing. A custom opener can be used by\n"
@@ -1123,22 +1123,22 @@ PyDoc_STRVAR(write_doc,
"write(b: bytes) -> int. Write bytes b to file, return number written.\n"
"\n"
"Only makes one system call, so not all of the data may be written.\n"
-"The number of bytes actually written is returned.");
+"The number of bytes actually written is returned. In non-blocking mode,\n"
+"returns None if the write would block."
+);
PyDoc_STRVAR(fileno_doc,
-"fileno() -> int. \"file descriptor\".\n"
-"\n"
-"This is needed for lower-level file interfaces, such the fcntl module.");
+"fileno() -> int. Return the underlying file descriptor (an integer).");
PyDoc_STRVAR(seek_doc,
"seek(offset: int[, whence: int]) -> int. Move to new file position and\n"
"return the file position.\n"
"\n"
"Argument offset is a byte count. Optional argument whence defaults to\n"
-"0 (offset from start of file, offset should be >= 0); other values are 1\n"
-"(move relative to current position, positive or negative), and 2 (move\n"
-"relative to end of file, usually negative, although many platforms allow\n"
-"seeking beyond the end of a file)."
+"SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values\n"
+"are SEEK_CUR or 1 (move relative to current position, positive or negative),\n"
+"and SEEK_END or 2 (move relative to end of file, usually negative, although\n"
+"many platforms allow seeking beyond the end of a file).\n"
"\n"
"Note that not all file objects are seekable.");
@@ -1152,7 +1152,10 @@ PyDoc_STRVAR(truncate_doc,
#endif
PyDoc_STRVAR(tell_doc,
-"tell() -> int. Current file position");
+"tell() -> int. Current file position.\n"
+"\n"
+"Can raise OSError for non seekable files."
+);
PyDoc_STRVAR(readinto_doc,
"readinto() -> Same as RawIOBase.readinto().");
@@ -1161,10 +1164,10 @@ PyDoc_STRVAR(close_doc,
"close() -> None. Close the file.\n"
"\n"
"A closed file cannot be used for further I/O operations. close() may be\n"
-"called more than once without error. Changes the fileno to -1.");
+"called more than once without error.");
PyDoc_STRVAR(isatty_doc,
-"isatty() -> bool. True if the file is connected to a tty device.");
+"isatty() -> bool. True if the file is connected to a TTY device.");
PyDoc_STRVAR(seekable_doc,
"seekable() -> bool. True if file supports random-access.");
@@ -1219,7 +1222,7 @@ get_mode(fileio *self, void *closure)
static PyGetSetDef fileio_getsetlist[] = {
{"closed", (getter)get_closed, NULL, "True if the file is closed"},
{"closefd", (getter)get_closefd, NULL,
- "True if the file descriptor will be closed"},
+ "True if the file descriptor will be closed by close()."},
{"mode", (getter)get_mode, NULL, "String giving the file mode"},
{NULL},
};