[issue4768] email.generator.Generator object bytes/str crash - b64encode() bug?

STINNER Victor report at bugs.python.org
Fri Jan 2 02:22:00 CET 2009


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

> I think the library function base64.b64encode() should return 
> a string, not bytes.

Yes, in the email module, the payload is an unicode string, not a 
bytes string. We have to be able to concatenate headers 
(eg. "Content-Type: image/fish\nMIME-Version: 
1.0\nContent-Transfer-Encoding: base64\n") and encoded data 
(eg. "R0lGO").

Attached patch implements this fix: encode_base64() returns str (and 
not bytes). The patchs fixes the unit tests and adds a new regression 
test for MIMEImage.as_string().

----------
nosy: +haypo

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4768>
_______________________________________


More information about the Python-bugs-list mailing list