This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 <1389425421.54.0.776848019246.issue20132@psf.upfronthosting.co.za>
In-reply-to
Content
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/codecs.py", line 1014, in iterencode
    output = encoder.encode("", True)
  File "/usr/lib/python3.3/encodings/base64_codec.py", line 31, in encode
    return base64.encodebytes(input)
  File "/usr/lib/python3.3/base64.py", 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.
History
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: <1389425421.54.0.776848019246.issue20132@psf.upfronthosting.co.za>
2014-01-11 07:30:21martin.panterlinkissue20132 messages
2014-01-11 07:30:20martin.pantercreate