Message234067
| Author |
lemburg |
| Recipients |
amcnabb, doerwalter, jcea, lemburg, loewis, martin.panter, vstinner |
| Date |
2015年01月15日.08:48:52 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<54B77EEC.5050503@egenix.com> |
| In-reply-to |
<1421296992.32.0.202312696753.issue13881@psf.upfronthosting.co.za> |
| Content |
On 15.01.2015 05:43, Martin Panter wrote:
>
> New patch that also fixes StreamWriter.writelines() in general for the byte codecs
Could you explain this new undocumented class ?
+class _IncrementalBasedWriter(StreamWriter):
+ """Generic StreamWriter implementation.
+
+ The _EncoderClass attribute must be set to an IncrementalEncoder
+ class to use.
+ """
+
+ def __init__(self, stream, errors='strict'):
+ super().__init__(stream, errors)
+ self._encoder = self._Encoder(errors)
+
+ def write(self, object):
+ self.stream.write(self._encoder.encode(object))
+
+ def reset(self):
+ self.stream.write(self._encoder.encode(final=True))
+
Note that the doc-string mentions a non-existing attribute and there
are doc-string missing for the other methods.
The purpose appears to be a StreamWriter which works with
an IncrementalEncoder. A proper name would thus be
IncrementalStreamWriter which provides an .encode()
method which adapts the signature of the incremental encoder
to the one expected for StreamWriters and Codecs. |
|