Walter Dörwald <wal...@livinglogic.de> added the comment: The documentation might be unclear here. But the argument iterator of
iterdecode(iterator, encoding, errors='strict', **kwargs) *is* supposed to be an iterable over bytes objects. In fact iterencode() transforms an iterator over strings into an iterator over bytes and iterdecode() transforms an iterator over bytes into an iterator over strings. Since iterating over strings iterates over the characters, it's possible to pass a string to iterencode(). However it's not possible to pass a bytes object to iterdecode() since iterating over a bytes object yields integers: >>> import codecs >>> list(codecs.iterencode(['spam'], 'utf-8')) [b'spam'] >>> list(codecs.iterencode('spam', 'utf-8')) [b's', b'p', b'a', b'm'] >>> list(codecs.iterdecode([b'spam'], 'utf-8')) ['spam'] >>> list(codecs.iterdecode(b'spam', 'utf-8')) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/codecs.py", line 1048, in iterdecode output = decoder.decode(input) File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/codecs.py", line 321, in decode data = self.buffer + input TypeError: can't concat int to bytes ---------- nosy: +doerwalter _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38482> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com