summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2007-04-16 22:10:50 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2007-04-16 22:10:50 (GMT)
commit3abcb013b8195aea38f80968d4111b5ac7e68c0b (patch)
treedffc08076dd91cbb7860e8115685b939d067a27f /Doc/lib
parent8981ad05c0f9c0edc8c2c7aeaad3615805abe907 (diff)
downloadcpython-3abcb013b8195aea38f80968d4111b5ac7e68c0b.zip
cpython-3abcb013b8195aea38f80968d4111b5ac7e68c0b.tar.gz
cpython-3abcb013b8195aea38f80968d4111b5ac7e68c0b.tar.bz2
Apply SF patch #1698994: Add getstate() and setstate()
methods to incrementalcodecs. Also forward port r54786 (fix the incremental utf_8_sig decoder).
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libcodecs.tex36
1 files changed, 36 insertions, 0 deletions
diff --git a/Doc/lib/libcodecs.tex b/Doc/lib/libcodecs.tex
index 05c0375..557364d 100644
--- a/Doc/lib/libcodecs.tex
+++ b/Doc/lib/libcodecs.tex
@@ -405,6 +405,21 @@ define in order to be compatible with the Python codec registry.
Reset the encoder to the initial state.
\end{methoddesc}
+\begin{methoddesc}{getstate}{}
+ Return the current state of the encoder which must be an integer.
+ The implementation should make sure that \code{0} is the most common state.
+ (States that are more complicated than integers can be converted into an
+ integer by marshaling/pickling the state and encoding the bytes of the
+ resulting string into an integer).
+ \versionadded{3.0}
+\end{methoddesc}
+
+\begin{methoddesc}{setstate}{state}
+ Set the state of the encoder to \var{state}. \var{state} must be an
+ encoder state returned by \method{getstate}.
+ \versionadded{3.0}
+\end{methoddesc}
+
\subsubsection{IncrementalDecoder Objects \label{incremental-decoder-objects}}
@@ -453,6 +468,27 @@ define in order to be compatible with the Python codec registry.
Reset the decoder to the initial state.
\end{methoddesc}
+\begin{methoddesc}{getstate}{}
+ Return the current state of the decoder. This must be a tuple with two
+ items, the first must be the buffer containing the still undecoded input.
+ The second must be an integer and can be additional state info.
+ (The implementation should make sure that \code{0} is the most common
+ additional state info.) If this additional state info is \code{0} it must
+ be possible to set the decoder to the state which has no input buffered
+ and \code{0} as the additional state info, so that feeding the previously
+ buffered input to the decoder returns it to the previous state without
+ producing any output. (Additional state info that is more complicated
+ than integers can be converted into an integer by marshaling/pickling
+ the info and encoding the bytes of the resulting string into an integer.)
+ \versionadded{3.0}
+\end{methoddesc}
+
+\begin{methoddesc}{setstate}{state}
+ Set the state of the encoder to \var{state}. \var{state} must be a
+ decoder state returned by \method{getstate}.
+ \versionadded{3.0}
+\end{methoddesc}
+
The \class{StreamWriter} and \class{StreamReader} classes provide
generic working interfaces which can be used to implement new