# HG changeset patch # User timeless@mozdev.org # Date 2015-10-15 02:21:05 # Node ID ab1af5e7d73460834dda349f9c97ca32d7800595 # Parent 90df14eb3d0e82f85a77ed6e4535c6d7654df7ae mail: drop python 2.5 support diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -70,31 +70,27 @@ class STARTTLS(smtplib.SMTP): self.does_esmtp = 0 return (resp, reply) -if util.safehasattr(smtplib.SMTP, '_get_socket'): - class SMTPS(smtplib.SMTP): - '''Derived class to verify the peer certificate for SMTPS. - - This class allows to pass any keyword arguments to SSL socket creation. - ''' - def __init__(self, sslkwargs, keyfile=None, certfile=None, **kwargs): - self.keyfile = keyfile - self.certfile = certfile - smtplib.SMTP.__init__(self, **kwargs) - self.default_port = smtplib.SMTP_SSL_PORT - self._sslkwargs = sslkwargs +class SMTPS(smtplib.SMTP): + '''Derived class to verify the peer certificate for SMTPS. - def _get_socket(self, host, port, timeout): - if self.debuglevel > 0: - print >> sys.stderr, 'connect:', (host, port) - new_socket = socket.create_connection((host, port), timeout) - new_socket = sslutil.wrapsocket(new_socket, - self.keyfile, self.certfile, - **self._sslkwargs) - self.file = smtplib.SSLFakeFile(new_socket) - return new_socket -else: - def SMTPS(sslkwargs, keyfile=None, certfile=None, **kwargs): - raise error.Abort(_('SMTPS requires Python 2.6 or later')) + This class allows to pass any keyword arguments to SSL socket creation. + ''' + def __init__(self, sslkwargs, keyfile=None, certfile=None, **kwargs): + self.keyfile = keyfile + self.certfile = certfile + smtplib.SMTP.__init__(self, **kwargs) + self.default_port = smtplib.SMTP_SSL_PORT + self._sslkwargs = sslkwargs + + def _get_socket(self, host, port, timeout): + if self.debuglevel > 0: + print >> sys.stderr, 'connect:', (host, port) + new_socket = socket.create_connection((host, port), timeout) + new_socket = sslutil.wrapsocket(new_socket, + self.keyfile, self.certfile, + **self._sslkwargs) + self.file = smtplib.SSLFakeFile(new_socket) + return new_socket def _smtp(ui): '''build an smtp connection and return a function to send mail'''