[issue31831] EmailMessage.add_attachment(filename="long or spécial") crashes or produces invalid output

2017-10-20 Thread calimeroteknik
New submission from calimeroteknik : The following code excerpt demonstrates a crash: import email.message mail = email.message.EmailMessage() mail.add_attachment( b"test", maintype = "text", subtype = "plain", filename = "I thought I could put a few words in the filename but appare

[issue31831] EmailMessage.add_attachment(filename="long or spécial") crashes or produces invalid output

2017-10-20 Thread calimeroteknik
calimeroteknik added the comment: Erratum: the output generated by python 3.5 and 3.4 causes line wraps in the SMTP delivery chain, which cause exactly the same breakage as ulterior versions: the crucially needed indendation of one space ends up being absent. -- versions: +Python 3.4,

[issue31831] EmailMessage.add_attachment(filename="long or spécial") crashes or produces invalid output

2017-10-20 Thread R. David Murray
R. David Murray added the comment: Does the patch in gh-3488 fix this? I think it should, or if it doesn't that's a bug in the PR patch. -- ___ Python tracker ___ ___

[issue31831] EmailMessage.add_attachment(filename="long or spécial") crashes or produces invalid output

2017-10-21 Thread calimeroteknik
calimeroteknik added the comment: I confirm that as for the crash, the patch in gh-3488 fixes it. The first code excerpt in my initial report now outputs the following, valid headers: Content-Type: text/plain Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename*0*=utf-8

[issue31831] EmailMessage.add_attachment(filename="long or spécial") crashes or produces invalid output

2017-10-21 Thread R. David Murray
R. David Murray added the comment: You are correct, that is a bug. Presumably I forgot to check for non-ascii when the parameter value doesn't need to be folded. I'm not sure when I'll have time to look at this, unfortunately :(. If you can see how to fix it, you could submit a PR against

[issue31831] EmailMessage.add_attachment(filename="long or spécial") crashes or produces invalid output

2017-10-21 Thread calimeroteknik
calimeroteknik added the comment: Eventually there is no bug, I was just confused at the output of print() on the EmailMessage. I noticed that in email/_header_value_parser.py policy.utf8 was True. The reason is found in email/message.py line 970 (class MIMEPart): def __str__(self):

[issue31831] EmailMessage.add_attachment(filename="long or spécial") crashes or produces invalid output

2017-10-22 Thread R. David Murray
R. David Murray added the comment: Great, thank you for that research. And yes, that's exactly why __str__ uses utf8=True, the "picture" of the message is much more readable. I will commit that PR soon. -- ___ Python tracker

[issue31831] EmailMessage.add_attachment(filename="long or spécial") crashes or produces invalid output

2017-12-03 Thread R. David Murray
R. David Murray added the comment: The PR has been committed. -- resolution: -> fixed stage: -> resolved status: open -> closed type: crash -> behavior versions: -Python 3.4, Python 3.5 ___ Python tracker