Marc-Andre Lemburg <m...@egenix.com> added the comment: Nick Coghlan wrote: > > As a separate, but related point, IncrementalDecoder.getstate() includes an > explanation on how to save arbitrary state as an integer, but no such > explanation (not even a reference to the IncrementalDecoder version) is > present in the IncrementalEncoder.getstate() docs. > > Adding MAL, since I'd like an expert opinion. Is the API less stringent than > the docs state, or should BufferedIncrementalEncoder be fixed to always > return the state as an integer? > > [1] > http://docs.python.org/dev/library/codecs#codecs.IncrementalEncoder.getstate
I'm not sure how that description got into the docs. It must have been added in the 3.x branch, since the 2.7 version of the docs doesn't document those method at all. FWIW: The .getstate() and .setstate() don't restrict the type of data used for storing the state. The only requirement is that the data returned by .getstate() can be passed to .setstate() in order to recreate the internal state used by the codec: def getstate(self): """ Return the current state of the encoder. """ return 0 def setstate(self, state): """ Set the current state of the encoder. state must have been returned by getstate(). """ For practical reasons, the used data should be pickleable. The interface is very similar to the __getstate__/__setstate__ interface used by pickle. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12808> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com