Author Oren Milman
Recipients Oren Milman
Date 2017-08-24.18:06:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503597989.21.0.785820469546.issue31271@psf.upfronthosting.co.za>
In-reply-to
Content
currently, the following causes an assertion in Modules/_io/textio.c in
_io_TextIOWrapper_write_impl() to fail:
import codecs
import io

class BadEncoder():
    def encode(self, dummy):
        return 42
def _get_bad_encoder(dummy):
    return BadEncoder()

quopri = codecs.lookup("quopri")
quopri._is_text_encoding = True
quopri.incrementalencoder = _get_bad_encoder
t = io.TextIOWrapper(io.BytesIO(b'foo'), encoding="quopri")
t.write('bar')


this is because _io_TextIOWrapper_write_impl() doesn't check whether the value
returned by encoder's encode() is a bytes object.

(I would open a PR to fix that soon.)
History
Date User Action Args
2017-08-24 18:06:29Oren Milmansetrecipients: + Oren Milman
2017-08-24 18:06:29Oren Milmansetmessageid: <1503597989.21.0.785820469546.issue31271@psf.upfronthosting.co.za>
2017-08-24 18:06:29Oren Milmanlinkissue31271 messages
2017-08-24 18:06:28Oren Milmancreate