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 vajrasky
Recipients Arfrever, apollo13, barry, r.david.murray, vajrasky
Date 2013-11-23.14:36:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
R. David Murray, your patch fails with this situation:

from email.mime.nonmultipart import *
from email.charset import *
from email.message import Message
from io import BytesIO
from email.generator import BytesGenerator
msg = Message()
cs = Charset('utf-8')
cs.body_encoding = None
msg.set_payload('АБВ', cs)
fp = BytesIO()
g = BytesGenerator(fp)

===> b'MIME-Version: 1.0\nContent-Type: text/plain; charset="utf-8"\nContent-Transfer-Encoding: base64\n\n0JDQkdCS\n'

Apparently, there is a funky bug. If you never call msg.as_string(), the fp.get_value() will output correctly:

b'MIME-Version: 1.0\nContent-Type: text/plain; charset="utf-8"\nContent-Transfer-Encoding: 8bit\n\n\xd0\x90\xd0\x91\xd0\x92'

It turns out that msg.as_string() calls set_payload with different kind of charset!

Attached the patch to solve this problem. Not sure whether this is important or not to fix in 3.3. How many people call bytes generator after calling string generator?
Date User Action Args
2013-11-23 14:36:02vajraskysetrecipients: + vajrasky, barry, Arfrever, r.david.murray, apollo13
2013-11-23 14:36:02vajraskysetmessageid: <>
2013-11-23 14:36:02vajraskylinkissue19063 messages
2013-11-23 14:36:01vajraskycreate