This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients amaury.forgeotdarc, arigo, gz, hyeshik.chang, lemburg, vstinner
Date 2011-05-26.00:14:08
SpamBayes Score 0.00031526902
Marked as misclassified No
Message-id <1306368849.68.0.326458647267.issue12171@psf.upfronthosting.co.za>
In-reply-to
Content
> I'm not sure what you mean by "discard the output".
> 
> Calling .reset() should still add the closing sequence to the output
> buffer, if needed.

Incremental encoders don't have any buffer.

Python 3.3a0 (default:3c7792ec4547+, May 26 2011, 00:24:51) 
>>> import codecs

>>> enc=codecs.lookup('hz').incrementalencoder()
>>> enc.encode('\u8000')
b'~{R+'
>>> enc.reset()

>>> enc.encode('\u8000')
b'~{R+'
>>> enc.encode('', final=True)
b'~}'

>>> import io
>>> buffer=io.BytesIO()
>>> enc=codecs.lookup('hz').streamwriter(buffer)
>>> enc.write('\u8000')
>>> buffer.getvalue()
b'~{R+'
>>> enc.reset()
>>> buffer.getvalue()
b'~{R+~}'

IncrementalEncoder.reset() may mention that the output is discarded:

   .. method:: reset()

      Reset the encoder to the initial state. The output is discarded: 
      use the ``encode('', final=True)`` method to reset the encoder 
      and to get the output.
History
Date User Action Args
2011-05-26 00:14:10vstinnersetrecipients: + vstinner, lemburg, arigo, amaury.forgeotdarc, hyeshik.chang, gz
2011-05-26 00:14:09vstinnersetmessageid: <1306368849.68.0.326458647267.issue12171@psf.upfronthosting.co.za>
2011-05-26 00:14:09vstinnerlinkissue12171 messages
2011-05-26 00:14:09vstinnercreate