@@ -33,6 +33,10 @@ giving a :class:`str` object to the ``write()`` method of a binary stream
3333will raise a ``TypeError ``. So will giving a :class: `bytes ` object to the
3434``write() `` method of a text stream.
3535
36+ .. versionchanged :: 3.3
37+ Operations defined in this module used to raise :exc: `IOError `, which is
38+ now an alias of :exc: `OSError `.
39+
3640
3741Text I/O
3842^^^^^^^^
@@ -115,7 +119,7 @@ High-level Module Interface
115119
116120.. exception :: UnsupportedOperation
117121
118- An exception inheriting :exc: `IOError ` and :exc: `ValueError ` that is raised
122+ An exception inheriting :exc: `OSError ` and :exc: `ValueError ` that is raised
119123 when an unsupported operation is called on a stream.
120124
121125
@@ -194,16 +198,16 @@ I/O Base Classes
194198 Even though :class: `IOBase ` does not declare :meth: `read `, :meth: `readinto `,
195199 or :meth: `write ` because their signatures will vary, implementations and
196200 clients should consider those methods part of the interface. Also,
197- implementations may raise a :exc: `IOError ` when operations they do not
198- support are called.
201+ implementations may raise a :exc: `ValueError ` (or :exc: ` UnsupportedOperation `)
202+ when operations they do not support are called.
199203
200204 The basic type used for binary data read from or written to a file is
201205 :class: `bytes `. :class: `bytearray `\s are accepted too, and in some cases
202206 (such as :class: `readinto `) required. Text I/O classes work with
203207 :class: `str ` data.
204208
205209 Note that calling any method (even inquiries) on a closed stream is
206- undefined. Implementations may raise :exc: `IOError ` in this case.
210+ undefined. Implementations may raise :exc: `ValueError ` in this case.
207211
208212 IOBase (and its subclasses) support the iterator protocol, meaning that an
209213 :class: `IOBase ` object can be iterated over yielding the lines in a stream.
@@ -236,7 +240,7 @@ I/O Base Classes
236240 .. method :: fileno()
237241
238242 Return the underlying file descriptor (an integer) of the stream if it
239- exists. An :exc: `IOError ` is raised if the IO object does not use a file
243+ exists. An :exc: `OSError ` is raised if the IO object does not use a file
240244 descriptor.
241245
242246 .. method :: flush()
@@ -252,7 +256,7 @@ I/O Base Classes
252256 .. method :: readable()
253257
254258 Return ``True `` if the stream can be read from. If False, :meth: `read `
255- will raise :exc: `IOError `.
259+ will raise :exc: `OSError `.
256260
257261 .. method :: readline(limit=-1)
258262
@@ -290,7 +294,7 @@ I/O Base Classes
290294 .. method :: seekable()
291295
292296 Return ``True `` if the stream supports random access. If ``False ``,
293- :meth: `seek `, :meth: `tell ` and :meth: `truncate ` will raise :exc: `IOError `.
297+ :meth: `seek `, :meth: `tell ` and :meth: `truncate ` will raise :exc: `OSError `.
294298
295299 .. method :: tell()
296300
@@ -308,7 +312,7 @@ I/O Base Classes
308312 .. method :: writable()
309313
310314 Return ``True `` if the stream supports writing. If ``False ``,
311- :meth: `write ` and :meth: `truncate ` will raise :exc: `IOError `.
315+ :meth: `write ` and :meth: `truncate ` will raise :exc: `OSError `.
312316
313317 .. method :: writelines(lines)
314318
@@ -442,7 +446,7 @@ I/O Base Classes
442446
443447 Write the given bytes or bytearray object, *b * and return the number
444448 of bytes written (never less than ``len(b) ``, since if the write fails
445- an :exc: `IOError ` will be raised). Depending on the actual
449+ an :exc: `OSError ` will be raised). Depending on the actual
446450 implementation, these bytes may be readily written to the underlying
447451 stream, or held in a buffer for performance and latency reasons.
448452
0 commit comments