Message354707
While working with codecs.iterdecode(), encountered "can't concat int to bytes". The source of the problem is BufferedIncrementalDecoder stores it's internal buffer as a bytes (ie: b""), but decode() can be passed either a byte string or in the case of iterdecode() an int. The solution is to test for this in the decode and if passed an int to coerce to bytes (see attach patch)
Platform: Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Code to demonstrate the issue:
>>> import codecs
>>> source = ''.join([chr(x) for x in range(256)])
>>> enc = b''.join(codecs.iterencode(source, 'utf-8'))
>>> list(''.join(codecs.iterdecode(enc, 'utf-8')))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python37\lib\codecs.py", line 1048, in iterdecode
output = decoder.decode(input)
File "C:\Python37\lib\codecs.py", line 321, in decode
data = self.buffer + input
TypeError: can't concat int to bytes |
|
Date |
User |
Action |
Args |
2019-10-15 08:21:30 | jamercee | set | recipients:
+ jamercee |
2019-10-15 08:21:30 | jamercee | set | messageid: <1571127690.05.0.477916235895.issue38482@roundup.psfhosted.org> |
2019-10-15 08:21:30 | jamercee | link | issue38482 messages |
2019-10-15 08:21:29 | jamercee | create | |
|