Patchwork [3,of,4] py3: use socket.makefile() instead of dropped smtplib.SSLFakeFile

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

Comments

Denis Laxalde - Oct. 10, 2019, 7:47 p.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1570735844 -7200
#      Thu Oct 10 21:30:44 2019 +0200
# Node ID 4439ff86e50d2d9c0ad63200cf22fa1c3461d3df
# Parent  134382b8c782147ab2fab155ebe79aa8df3b435c
py3: use socket.makefile() instead of dropped smtplib.SSLFakeFile

The latter (undocumented internal) class got removed in Python 3.3. Use
socket.makefile() as suggested:

  https://docs.python.org/3/whatsnew/3.3.html#porting-python-code

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
index 519cc3b..0d2139b 100644
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -61,7 +61,7 @@  class STARTTLS(smtplib.SMTP):
                 ui=self._ui,
                 serverhostname=self._host,
             )
-            self.file = smtplib.SSLFakeFile(self.sock)
+            self.file = self.sock.makefile("rb")
             self.helo_resp = None
             self.ehlo_resp = None
             self.esmtp_features = {}