Message226679
Stream reader interfaces suffer the same problem. Test cases:
codecs.getreader("unicode-escape")(BytesIO(br"\u2013")).read(1)
codecs.getreader("hex-codec")(BytesIO(b"33")).read(1)
codecs.getreader("base64-codec")(BytesIO(b"AA==")).read(1)
TestCase().assertEqual(b"=", codecs.getreader("quopri-codec")(BytesIO(b"=3D")).read(1))
Even though the “zlib” incremental decoder is okay, its stream reader still suffers this problem. I was going to check for zip bomb behaviour when you call read() with a limited number of input “characters”, but got this instead:
>>> codecs.getreader("zlib-codec")(bomb).read(1, 1)
zlib.error: Error -5 while decompressing data: incomplete or truncated stream
Similar problems with stream writers, for instance:
>>> w = codecs.getwriter("base64-codec")(BytesIO())
>>> w.write(b"1"); w.write(b"2"); w.reset(); w.getvalue()
b'MQ==\nMg==\n' # Should be b"MTI=\n"
I also noticed StreamWriter.writelines() assumes it is encoding text, and does not work at least with “base64-codec”:
>>>> codecs.getwriter("base64-codec")(BytesIO()).writelines((b"1", b"2"))
TypeError: sequence item 0: expected str instance, bytes found |
|
Date |
User |
Action |
Args |
2014-09-10 05:16:57 | martin.panter | set | recipients:
+ martin.panter, lemburg, loewis, doerwalter, ncoghlan, vstinner |
2014-09-10 05:16:57 | martin.panter | set | messageid: <1410326217.24.0.956945864029.issue20132@psf.upfronthosting.co.za> |
2014-09-10 05:16:57 | martin.panter | link | issue20132 messages |
2014-09-10 05:16:56 | martin.panter | create | |
|