M.-A. Lemburg wrote:
I'll write up a PEP once we have a better understanding of the
details, e.g. of how the codec type information should be
defined...

Here's a straight-forward approach:

codecinfo.encode_type_combinations = [(bytes, bytes), (str, str)]
codecinfo.decode_type_combinations = [(bytes, bytes), (str, str)]

for most codecs (e.g. utf-8, latin-1, cp850, etc.) this would
then be:

codecinfo.encode_type_combinations = [(str, bytes)]
codecinfo.decode_type_combinations = [(bytes, str)]

Do we need something that flexible? Would a simpler approach with separate "binary_transform" and "text_transform" flags be enough?

With the latter approach, the encode()/decode() methods could complain if either of the transform flags was set on the codec, while the transform()/untransform() methods could complain if the appropriate transform flag *wasn't* set.

Note also that both bytearray and bytes provide decode() methods, and will presumably provide transform() methods, so actual type annotations may not be the best way to go about this.

Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to