Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 291331 | Differences between
and this patch

Collapse All | Expand All

(-)pym/portage/mail.py (-2 / +12 lines)
Lines 14-20 Link Here
14
14
15
from portage import os
15
from portage import os
16
from portage import _encodings
16
from portage import _encodings
17
from portage import _unicode_encode
17
from portage import _unicode_decode, _unicode_encode
18
from portage.localization import _
18
from portage.localization import _
19
import portage
19
import portage
20
20
Lines 135-141 Link Here
135
				myconn = smtplib.SMTP(mymailhost, mymailport)
135
				myconn = smtplib.SMTP(mymailhost, mymailport)
136
			if mymailuser != "" and mymailpasswd != "":
136
			if mymailuser != "" and mymailpasswd != "":
137
				myconn.login(mymailuser, mymailpasswd)
137
				myconn.login(mymailuser, mymailpasswd)
138
			myconn.sendmail(myfrom, myrecipient, message.as_string())
138
139
			message_str = message.as_string()
140
			if sys.hexversion >= 0x3000000:
141
				# Force ascii encoding in order to avoid UnicodeEncodeError
142
				# from smtplib.sendmail with python3 (bug #291331).
143
				message_str = _unicode_encode(message_str,
144
					encoding='ascii', errors='backslashreplace')
145
				message_str = _unicode_decode(message_str,
146
					encoding='ascii', errors='replace')
147
148
			myconn.sendmail(myfrom, myrecipient, message_str)
139
			myconn.quit()
149
			myconn.quit()
140
		except smtplib.SMTPException as e:
150
		except smtplib.SMTPException as e:
141
			raise portage.exception.PortageException(_("!!! An error occured while trying to send logmail:\n")+str(e))
151
			raise portage.exception.PortageException(_("!!! An error occured while trying to send logmail:\n")+str(e))

Return to bug 291331