Patchwork [1,of,4] py3: call SMTP.has_extn() with an str

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 10, 2019, 7:47 p.m.
Message ID <55a0f0c84fdc2170047e.1570736848@marimba>
Download mbox | patch
Permalink /patch/42193/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 10, 2019, 7:47 p.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1570734013 -7200
#      Thu Oct 10 21:00:13 2019 +0200
# Node ID 55a0f0c84fdc2170047ea99f71bfac60e3ea4b50
# Parent  a5b04863dbff8c9a0966ee47c8a27675bdcdf2b8
py3: call SMTP.has_extn() with an str

Passing a bytes on Python 3 always returns False, thus starttls is not
properly detected.
Yuya Nishihara - Oct. 11, 2019, 11:45 a.m.
On Thu, 10 Oct 2019 21:47:28 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@laxalde.org>
> # Date 1570734013 -7200
> #      Thu Oct 10 21:00:13 2019 +0200
> # Node ID 55a0f0c84fdc2170047ea99f71bfac60e3ea4b50
> # Parent  a5b04863dbff8c9a0966ee47c8a27675bdcdf2b8
> py3: call SMTP.has_extn() with an str

Queued, thanks.

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
index e67603a..675207a 100644
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -49,7 +49,7 @@  class STARTTLS(smtplib.SMTP):
         self._host = host
 
     def starttls(self, keyfile=None, certfile=None):
-        if not self.has_extn(b"starttls"):
+        if not self.has_extn("starttls"):
             msg = b"STARTTLS extension not supported by server"
             raise smtplib.SMTPException(msg)
         (resp, reply) = self.docmd(b"STARTTLS")