| OLD | NEW |
| 1 """The io module provides the Python interfaces to stream handling. The | 1 """The io module provides the Python interfaces to stream handling. The |
| 2 builtin open function is defined in this module. | 2 builtin open function is defined in this module. |
| 3 | 3 |
| 4 At the top of the I/O hierarchy is the abstract base class IOBase. It | 4 At the top of the I/O hierarchy is the abstract base class IOBase. It |
| 5 defines the basic interface to a stream. Note, however, that there is no | 5 defines the basic interface to a stream. Note, however, that there is no |
| 6 seperation between reading and writing to streams; implementations are | 6 seperation between reading and writing to streams; implementations are |
| 7 allowed to throw an IOError if they do not support a given operation. | 7 allowed to throw an IOError if they do not support a given operation. |
| 8 | 8 |
| 9 Extending IOBase is RawIOBase which deals simply with the reading and | 9 Extending IOBase is RawIOBase which deals simply with the reading and |
| 10 writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide | 10 writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 a file in a binary mode, the returned class varies: in read binary | 173 a file in a binary mode, the returned class varies: in read binary |
| 174 mode, it returns a BufferedReader; in write binary and append binary | 174 mode, it returns a BufferedReader; in write binary and append binary |
| 175 modes, it returns a BufferedWriter, and in read/write mode, it returns | 175 modes, it returns a BufferedWriter, and in read/write mode, it returns |
| 176 a BufferedRandom. | 176 a BufferedRandom. |
| 177 | 177 |
| 178 It is also possible to use a string or bytearray as a file for both | 178 It is also possible to use a string or bytearray as a file for both |
| 179 reading and writing. For strings StringIO can be used like a file | 179 reading and writing. For strings StringIO can be used like a file |
| 180 opened in a text mode, and for bytes a BytesIO can be used like a file | 180 opened in a text mode, and for bytes a BytesIO can be used like a file |
| 181 opened in a binary mode. | 181 opened in a binary mode. |
| 182 """ | 182 """ |
| 183 if not isinstance(file, (str, int)): | 183 if not isinstance(file, (str, bytes, int)): |
| 184 raise TypeError("invalid file: %r" % file) | 184 raise TypeError("invalid file: %r" % file) |
| 185 if not isinstance(mode, str): | 185 if not isinstance(mode, str): |
| 186 raise TypeError("invalid mode: %r" % mode) | 186 raise TypeError("invalid mode: %r" % mode) |
| 187 if buffering is not None and not isinstance(buffering, int): | 187 if buffering is not None and not isinstance(buffering, int): |
| 188 raise TypeError("invalid buffering: %r" % buffering) | 188 raise TypeError("invalid buffering: %r" % buffering) |
| 189 if encoding is not None and not isinstance(encoding, str): | 189 if encoding is not None and not isinstance(encoding, str): |
| 190 raise TypeError("invalid encoding: %r" % encoding) | 190 raise TypeError("invalid encoding: %r" % encoding) |
| 191 if errors is not None and not isinstance(errors, str): | 191 if errors is not None and not isinstance(errors, str): |
| 192 raise TypeError("invalid errors: %r" % errors) | 192 raise TypeError("invalid errors: %r" % errors) |
| 193 modes = set(mode) | 193 modes = set(mode) |
| (...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2127 ("\r", "\n"), | 2127 ("\r", "\n"), |
| 2128 "\r\n", | 2128 "\r\n", |
| 2129 ("\n", "\r\n"), | 2129 ("\n", "\r\n"), |
| 2130 ("\r", "\r\n"), | 2130 ("\r", "\r\n"), |
| 2131 ("\r", "\n", "\r\n") | 2131 ("\r", "\n", "\r\n") |
| 2132 )[self._seennl] | 2132 )[self._seennl] |
| 2133 | 2133 |
| 2134 | 2134 |
| 2135 except ImportError: | 2135 except ImportError: |
| 2136 StringIO = _StringIO | 2136 StringIO = _StringIO |
| OLD | NEW |