Mercurial > public > mercurial-scm > hg
comparison mercurial/mail.py @ 36047:1407c42b302c
py3: pass system string to email.message.Message.set_type()
Python 3 insists the type is a str.
Differential Revision: https://phab.mercurial-scm.org/D2149
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 14:25:10 -0800 |
parents | b45a9d121b53 |
children | 9e47bfbeb723 |
comparison
equal
deleted
inserted
replaced
36046:a5cf79755eff | 36047:1407c42b302c |
---|---|
18 | 18 |
19 from .i18n import _ | 19 from .i18n import _ |
20 from . import ( | 20 from . import ( |
21 encoding, | 21 encoding, |
22 error, | 22 error, |
23 pycompat, | |
23 sslutil, | 24 sslutil, |
24 util, | 25 util, |
25 ) | 26 ) |
26 | 27 |
27 class STARTTLS(smtplib.SMTP): | 28 class STARTTLS(smtplib.SMTP): |
216 '''Return MIME message. | 217 '''Return MIME message. |
217 Quoted-printable transfer encoding will be used if necessary. | 218 Quoted-printable transfer encoding will be used if necessary. |
218 ''' | 219 ''' |
219 cs = email.charset.Charset(charset) | 220 cs = email.charset.Charset(charset) |
220 msg = email.message.Message() | 221 msg = email.message.Message() |
221 msg.set_type('text/' + subtype) | 222 msg.set_type(pycompat.sysstr('text/' + subtype)) |
222 | 223 |
223 for line in body.splitlines(): | 224 for line in body.splitlines(): |
224 if len(line) > 950: | 225 if len(line) > 950: |
225 cs.body_encoding = email.charset.QP | 226 cs.body_encoding = email.charset.QP |
226 break | 227 break |