Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(14581)

Delta Between Two Patch Sets: Doc/library/fileinput.rst

Issue 25788: fileinput.hook_encoded has no way to pass arguments to codecs
Left Patch Set: Created 3 years, 4 months ago
Right Patch Set: Created 3 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Doc/whatsnew/3.6.rst » ('j') | Doc/whatsnew/3.6.rst » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 :mod:`fileinput` --- Iterate over lines from multiple input streams 1 :mod:`fileinput` --- Iterate over lines from multiple input streams
2 =================================================================== 2 ===================================================================
3 3
4 .. module:: fileinput 4 .. module:: fileinput
5 :synopsis: Loop over standard input or a list of files. 5 :synopsis: Loop over standard input or a list of files.
6 .. moduleauthor:: Guido van Rossum <guido@python.org> 6 .. moduleauthor:: Guido van Rossum <guido@python.org>
7 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org> 7 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
8 8
9 **Source code:** :source:`Lib/fileinput.py` 9 **Source code:** :source:`Lib/fileinput.py`
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 .. function:: hook_compressed(filename, mode) 181 .. function:: hook_compressed(filename, mode)
182 182
183 Transparently opens files compressed with gzip and bzip2 (recognized by the 183 Transparently opens files compressed with gzip and bzip2 (recognized by the
184 extensions ``'.gz'`` and ``'.bz2'``) using the :mod:`gzip` and :mod:`bz2` 184 extensions ``'.gz'`` and ``'.bz2'``) using the :mod:`gzip` and :mod:`bz2`
185 modules. If the filename extension is not ``'.gz'`` or ``'.bz2'``, the file is 185 modules. If the filename extension is not ``'.gz'`` or ``'.bz2'``, the file is
186 opened normally (ie, using :func:`open` without any decompression). 186 opened normally (ie, using :func:`open` without any decompression).
187 187
188 Usage example: ``fi = fileinput.FileInput(openhook=fileinput.hook_compressed )`` 188 Usage example: ``fi = fileinput.FileInput(openhook=fileinput.hook_compressed )``
189 189
190 190
191 .. function:: hook_encoded(encoding) 191 .. function:: hook_encoded(encoding, errors=None)
192 192
193 Returns a hook which opens each file with :func:`codecs.open`, using the give n 193 Returns a hook which opens each file with :func:`codecs.open`, using the give n
194 *encoding* to read the file. 194 *encoding* to read the file. *errors* is an optional string that specifies ho w
storchaka 2016/04/27 22:14:52 Line is too long. It is recommended to use two spa
195 encoding and decoding errors are to be handled--this cannot be used in binary
196 mode. A variety of standard error handlers are available (listed under
197 :ref:`error-handlers`).
195 198
196 Usage example: ``fi = 199 Usage example: ``fi =
197 fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1"))`` 200 fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1", errors="rep lace"))``
storchaka 2016/04/27 22:14:52 Bad example. Decoding "iso-8859-1" never fails. Sh
201
202 .. versionchanged:: 3.6
203 Added the *errors* keyword argument.
storchaka 2016/04/27 22:14:52 Changed to "Added the optional *errors* parameter.
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+