[issue19619] Blacklist base64, hex, ... codecs from bytes.decode() and str.encode()

Marc-Andre Lemburg report at bugs.python.org
Fri Nov 22 12:28:03 CET 2013


Marc-Andre Lemburg added the comment:

On 22.11.2013 12:24, Marc-Andre Lemburg wrote:
> 
> Nick: I've had a look at your second patch. A couple of notes:
> 
>  * I think you should add the flag to the constructor of the CodecInfo
>    tuple subclass and then set this in the resp. codecs. The extra
>    constructor class method looks too much like a hack and is
>    not needed.

Like this:

    _is_text_encoding = True # Assume codecs are text encodings by default

    def __new__(cls, encode, decode, streamreader=None, streamwriter=None,
        incrementalencoder=None, incrementaldecoder=None, name=None,
        _is_text_encoding=None):
        self = tuple.__new__(cls, (encode, decode, streamreader, streamwriter))
        self.name = name
        self.encode = encode
        self.decode = decode
        self.incrementalencoder = incrementalencoder
        self.incrementaldecoder = incrementaldecoder
        self.streamwriter = streamwriter
        self.streamreader = streamreader
        if _is_text_encoding is not None:
            self._is_text_encoding = _is_text_encoding
        return self

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19619>
_______________________________________


More information about the Python-bugs-list mailing list