Author martin.panter
Recipients doerwalter, lemburg, loewis, martin.panter, ncoghlan, vstinner
Date 2014-01-11.07:30:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I think calling iterencode() with an empty iterator is a side issue. Even with a non-empty iterator, it tries to encode an empty _text_ string to finalise the encoder:

>>> bytes().join(codecs.iterencode(iter((b"data",)), "base64-codec"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.3/", line 1014, in iterencode
    output = encoder.encode("", True)
  File "/usr/lib/python3.3/encodings/", line 31, in encode
    return base64.encodebytes(input)
  File "/usr/lib/python3.3/", line 343, in encodebytes
    raise TypeError("expected bytes, not %s" % s.__class__.__name__)
TypeError: expected bytes, not str

Similarly, iterdecode(encoding="rot-13") doesn’t work. I agree it would be good to document that iterencode() is limited to text encoders and iterdecode() is limited to byte decoders.
Date User Action Args
2014-01-11 07:30:21martin.pantersetrecipients: + martin.panter, lemburg, loewis, doerwalter, ncoghlan, vstinner
2014-01-11 07:30:21martin.pantersetmessageid: <>
2014-01-11 07:30:21martin.panterlinkissue20132 messages
2014-01-11 07:30:20martin.pantercreate