mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Return complete lines from codec stream readers
even if there is an exception in later lines, resulting in correct line numbers for decoding errors in source code. Fixes #1178484. Will backport to 2.4.
This commit is contained in:
parent
6d2b346140
commit
56066d2e55
3 changed files with 26 additions and 4 deletions
|
|
@ -394,7 +394,7 @@ order to be compatible to the Python codec registry.
|
|||
be extended with \function{register_error()}.
|
||||
\end{classdesc}
|
||||
|
||||
\begin{methoddesc}{read}{\optional{size\optional{, chars}}}
|
||||
\begin{methoddesc}{read}{\optional{size\optional{, chars, \optional{firstline}}}}
|
||||
Decodes data from the stream and returns the resulting object.
|
||||
|
||||
\var{chars} indicates the number of characters to read from the
|
||||
|
|
@ -408,12 +408,16 @@ order to be compatible to the Python codec registry.
|
|||
decode as much as possible. \var{size} is intended to prevent having
|
||||
to decode huge files in one step.
|
||||
|
||||
\var{firstline} indicates that it would be sufficient to only return
|
||||
the first line, if there are decoding errors on later lines.
|
||||
|
||||
The method should use a greedy read strategy meaning that it should
|
||||
read as much data as is allowed within the definition of the encoding
|
||||
and the given size, e.g. if optional encoding endings or state
|
||||
markers are available on the stream, these should be read too.
|
||||
|
||||
\versionchanged[\var{chars} argument added]{2.4}
|
||||
\versionchanged[\var{firstline} argument added]{2.4.2}
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{readline}{\optional{size\optional{, keepends}}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue