Fix mentions of IOError in the io module docs

This commit is contained in:
Antoine Pitrou 2011-10-12 19:02:52 +02:00
parent f55011f8b6
commit a787b650d4
1 changed files with 13 additions and 9 deletions

View File

@ -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
``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
^^^^^^^^
@ -115,7 +119,7 @@ High-level Module Interface
.. 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.
@ -194,8 +198,8 @@ I/O Base Classes
Even though :class:`IOBase` does not declare :meth:`read`, :meth:`readinto`,
or :meth:`write` because their signatures will vary, implementations and
clients should consider those methods part of the interface. Also,
implementations may raise a :exc:`IOError` when operations they do not
support are called.
implementations may raise a :exc:`ValueError` (or :exc:`UnsupportedOperation`)
when operations they do not support are called.
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
@ -203,7 +207,7 @@ I/O Base Classes
:class:`str` data.
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
:class:`IOBase` object can be iterated over yielding the lines in a stream.
@ -236,7 +240,7 @@ I/O Base Classes
.. method:: fileno()
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.
.. method:: flush()
@ -252,7 +256,7 @@ I/O Base Classes
.. method:: readable()
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)
@ -290,7 +294,7 @@ I/O Base Classes
.. method:: seekable()
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()
@ -308,7 +312,7 @@ I/O Base Classes
.. method:: writable()
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)
@ -442,7 +446,7 @@ I/O Base Classes
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
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
stream, or held in a buffer for performance and latency reasons.