Author inada.naoki
Recipients Arfrever, berker.peksag, inada.naoki, ishimoto, jwilk, loewis, martin.panter, mrabarnett, ncoghlan, nikratio, pitrou, quad, rurpy2, serhiy.storchaka, vstinner
Date 2017-01-10.13:20:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1484054409.6.0.0112956238648.issue15216@psf.upfronthosting.co.za>
In-reply-to
Content
This patch doesn't change current behavior of "decode by chunk".
It's difficult to support changing encoding via header, like
Python's encoding cookie.

>>> import io
>>> buff = io.BytesIO("hello\nこんにちは".encode('utf-8'))
>>> f = io.TextIOWrapper(buff, encoding='ascii')
>>> f.readline()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/inada-n/work/python/cpython/Lib/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 6: ordinal not in range(128)
>>>
>>> buff = io.BytesIO("hello\nこんにちは".encode('utf-8'))
>>> f = io.TextIOWrapper(buff, encoding='ascii')
>>> f.read(6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/inada-n/work/python/cpython/Lib/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 6: ordinal not in range(128)
History
Date User Action Args
2017-01-10 13:20:09inada.naokisetrecipients: + inada.naoki, loewis, ishimoto, ncoghlan, pitrou, vstinner, jwilk, mrabarnett, Arfrever, nikratio, rurpy2, berker.peksag, martin.panter, serhiy.storchaka, quad
2017-01-10 13:20:09inada.naokisetmessageid: <1484054409.6.0.0112956238648.issue15216@psf.upfronthosting.co.za>
2017-01-10 13:20:09inada.naokilinkissue15216 messages
2017-01-10 13:20:09inada.naokicreate