Andrew Kuchling wrote:
The codec design allows extending the constructors using keyword arguments, however I'd rather not add a generic **kws argument to the base classes since this would hide errors (unknown or unsupported keywords, mispellings, etc.).
Isn't such an argument required at least for StreamReaderWriter, because it actually instantiates two objects?
class StreamReaderWriter: def __init__(self, stream, Reader, Writer, errors='strict'):
""" ... Reader, Writer must be factory functions or classes providing the StreamReader, StreamWriter interface resp. """ self.stream = stream self.reader = Reader(stream, errors) self.writer = Writer(stream, errors)
Hmm... you'd better not need to have two different set of keyword arguments for Reader and Writer. Is that limitation acceptable?
Should be OK since both work on the same stream backend and thus will normally use the same encoding parameters.
If it is, then the list of changes becomes 1) add **kw to codecs.open, and 2) add **kw to StreamReaderWriter's constructor, and apply it to the Reader() and Writer() calls.
The encoder and decoder functions must work stateless.
OK, then they're not suitable for encryption (in general, though they'd work fine for ECB mode).
Right; would it be feasable to use ECB ciphers for the stateless part and also allow other modes for the StreamReader/Writer ?