mirror of
https://github.com/python/cpython.git
synced 2025-09-26 02:10:18 +00:00
Fix mentions of IOError in the io module docs
This commit is contained in:
parent
f55011f8b6
commit
a787b650d4
1 changed files with 13 additions and 9 deletions
|
@ -33,6 +33,10 @@ giving a :class:`str` object to the ``write()`` method of a binary stream
|
||||||
will raise a ``TypeError``. So will giving a :class:`bytes` object to the
|
will raise a ``TypeError``. So will giving a :class:`bytes` object to the
|
||||||
``write()`` method of a text stream.
|
``write()`` method of a text stream.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.3
|
||||||
|
Operations defined in this module used to raise :exc:`IOError`, which is
|
||||||
|
now an alias of :exc:`OSError`.
|
||||||
|
|
||||||
|
|
||||||
Text I/O
|
Text I/O
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
|
@ -115,7 +119,7 @@ High-level Module Interface
|
||||||
|
|
||||||
.. exception:: UnsupportedOperation
|
.. exception:: UnsupportedOperation
|
||||||
|
|
||||||
An exception inheriting :exc:`IOError` and :exc:`ValueError` that is raised
|
An exception inheriting :exc:`OSError` and :exc:`ValueError` that is raised
|
||||||
when an unsupported operation is called on a stream.
|
when an unsupported operation is called on a stream.
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,8 +198,8 @@ I/O Base Classes
|
||||||
Even though :class:`IOBase` does not declare :meth:`read`, :meth:`readinto`,
|
Even though :class:`IOBase` does not declare :meth:`read`, :meth:`readinto`,
|
||||||
or :meth:`write` because their signatures will vary, implementations and
|
or :meth:`write` because their signatures will vary, implementations and
|
||||||
clients should consider those methods part of the interface. Also,
|
clients should consider those methods part of the interface. Also,
|
||||||
implementations may raise a :exc:`IOError` when operations they do not
|
implementations may raise a :exc:`ValueError` (or :exc:`UnsupportedOperation`)
|
||||||
support are called.
|
when operations they do not support are called.
|
||||||
|
|
||||||
The basic type used for binary data read from or written to a file is
|
The basic type used for binary data read from or written to a file is
|
||||||
:class:`bytes`. :class:`bytearray`\s are accepted too, and in some cases
|
:class:`bytes`. :class:`bytearray`\s are accepted too, and in some cases
|
||||||
|
@ -203,7 +207,7 @@ I/O Base Classes
|
||||||
:class:`str` data.
|
:class:`str` data.
|
||||||
|
|
||||||
Note that calling any method (even inquiries) on a closed stream is
|
Note that calling any method (even inquiries) on a closed stream is
|
||||||
undefined. Implementations may raise :exc:`IOError` in this case.
|
undefined. Implementations may raise :exc:`ValueError` in this case.
|
||||||
|
|
||||||
IOBase (and its subclasses) support the iterator protocol, meaning that an
|
IOBase (and its subclasses) support the iterator protocol, meaning that an
|
||||||
:class:`IOBase` object can be iterated over yielding the lines in a stream.
|
:class:`IOBase` object can be iterated over yielding the lines in a stream.
|
||||||
|
@ -236,7 +240,7 @@ I/O Base Classes
|
||||||
.. method:: fileno()
|
.. method:: fileno()
|
||||||
|
|
||||||
Return the underlying file descriptor (an integer) of the stream if it
|
Return the underlying file descriptor (an integer) of the stream if it
|
||||||
exists. An :exc:`IOError` is raised if the IO object does not use a file
|
exists. An :exc:`OSError` is raised if the IO object does not use a file
|
||||||
descriptor.
|
descriptor.
|
||||||
|
|
||||||
.. method:: flush()
|
.. method:: flush()
|
||||||
|
@ -252,7 +256,7 @@ I/O Base Classes
|
||||||
.. method:: readable()
|
.. method:: readable()
|
||||||
|
|
||||||
Return ``True`` if the stream can be read from. If False, :meth:`read`
|
Return ``True`` if the stream can be read from. If False, :meth:`read`
|
||||||
will raise :exc:`IOError`.
|
will raise :exc:`OSError`.
|
||||||
|
|
||||||
.. method:: readline(limit=-1)
|
.. method:: readline(limit=-1)
|
||||||
|
|
||||||
|
@ -290,7 +294,7 @@ I/O Base Classes
|
||||||
.. method:: seekable()
|
.. method:: seekable()
|
||||||
|
|
||||||
Return ``True`` if the stream supports random access. If ``False``,
|
Return ``True`` if the stream supports random access. If ``False``,
|
||||||
:meth:`seek`, :meth:`tell` and :meth:`truncate` will raise :exc:`IOError`.
|
:meth:`seek`, :meth:`tell` and :meth:`truncate` will raise :exc:`OSError`.
|
||||||
|
|
||||||
.. method:: tell()
|
.. method:: tell()
|
||||||
|
|
||||||
|
@ -308,7 +312,7 @@ I/O Base Classes
|
||||||
.. method:: writable()
|
.. method:: writable()
|
||||||
|
|
||||||
Return ``True`` if the stream supports writing. If ``False``,
|
Return ``True`` if the stream supports writing. If ``False``,
|
||||||
:meth:`write` and :meth:`truncate` will raise :exc:`IOError`.
|
:meth:`write` and :meth:`truncate` will raise :exc:`OSError`.
|
||||||
|
|
||||||
.. method:: writelines(lines)
|
.. method:: writelines(lines)
|
||||||
|
|
||||||
|
@ -442,7 +446,7 @@ I/O Base Classes
|
||||||
|
|
||||||
Write the given bytes or bytearray object, *b* and return the number
|
Write the given bytes or bytearray object, *b* and return the number
|
||||||
of bytes written (never less than ``len(b)``, since if the write fails
|
of bytes written (never less than ``len(b)``, since if the write fails
|
||||||
an :exc:`IOError` will be raised). Depending on the actual
|
an :exc:`OSError` will be raised). Depending on the actual
|
||||||
implementation, these bytes may be readily written to the underlying
|
implementation, these bytes may be readily written to the underlying
|
||||||
stream, or held in a buffer for performance and latency reasons.
|
stream, or held in a buffer for performance and latency reasons.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue