[New-bugs-announce] [issue31271] an assertion failure in io.TextIOWrapper.write
Oren Milman
report at bugs.python.org
Thu Aug 24 14:06:29 EDT 2017
New submission from Oren Milman:
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.)
----------
components: IO
messages: 300795
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: an assertion failure in io.TextIOWrapper.write
type: crash
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31271>
_______________________________________
More information about the New-bugs-announce
mailing list