commit: 7204b87040edfcf0924f2d3647d5a00e1de7a170 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Thu Sep 11 22:51:21 2014 +0000 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> CommitDate: Thu Sep 11 23:01:14 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7204b870
portage/mail.py: Make email date, timestamp RFC-compliant Bug 520752 Apply patch from Florent Bondoux f.bondoux <AT> free.fr Remove no longer used time import. Wrap the fromatedate() call with _unicode_encode() to prevent any encoding issues. X-Gentoo-Bug: 520752 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=520752 Reviewed-by: Zac Medico --- pym/portage/mail.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pym/portage/mail.py b/pym/portage/mail.py index 723da04..2efcbba 100644 --- a/pym/portage/mail.py +++ b/pym/portage/mail.py @@ -12,7 +12,6 @@ import socket import sys -import time from portage import os from portage import _encodings @@ -49,6 +48,7 @@ def create_message(sender, recipient, subject, body, attachments=None): from email.header import Header from email.mime.base import MIMEBase as BaseMessage from email.mime.multipart import MIMEMultipart as MultipartMessage + from email.utils import formatdate if sys.hexversion < 0x3000000: sender = _unicode_encode(sender, @@ -91,8 +91,9 @@ def create_message(sender, recipient, subject, body, attachments=None): # input_bytes = s.encode(input_charset, errors) #UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-9: ordinal not in range(128) mymessage["Subject"] = Header(_force_ascii_if_necessary(subject)) - mymessage["Date"] = time.strftime("%a, %d %b %Y %H:%M:%S %z") - + mymessage["Date"] = _unicode_encode(formatdate(localtime=True), + encoding=_encodings['content'], errors='backslashreplace') + return mymessage def send_mail(mysettings, message):