Patchwork mail: drop python 2.5 support

login
register
mail settings
Submitter timeless@mozdev.org
Date Oct. 15, 2015, 2:26 a.m.
Message ID <ec4dbd378f47239acad8.1444875998@waste.org>
Download mbox | patch
Permalink /patch/11094/
State Accepted
Headers show

Comments

timeless@mozdev.org - Oct. 15, 2015, 2:26 a.m.
# HG changeset patch
# User timeless@mozdev.org
# Date 1444875665 14400
#      Wed Oct 14 22:21:05 2015 -0400
# Node ID ec4dbd378f47239acad89a2e44b3a0fc4d8ce019
# Parent  07db7e95c464537aeb2dd7aba39de0813eaffd04
mail: drop python 2.5 support
Augie Fackler - Oct. 15, 2015, 1:04 p.m.
On Wed, Oct 14, 2015 at 09:26:38PM -0500, timeless@mozdev.org wrote:
> # HG changeset patch
> # User timeless@mozdev.org
> # Date 1444875665 14400
> #      Wed Oct 14 22:21:05 2015 -0400
> # Node ID ec4dbd378f47239acad89a2e44b3a0fc4d8ce019
> # Parent  07db7e95c464537aeb2dd7aba39de0813eaffd04
> mail: drop python 2.5 support

queued, very nice catch

>
> diff --git a/mercurial/mail.py b/mercurial/mail.py
> --- a/mercurial/mail.py
> +++ b/mercurial/mail.py
> @@ -70,31 +70,27 @@
>              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.
> +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
> +    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
> -else:
> -    def SMTPS(sslkwargs, keyfile=None, certfile=None, **kwargs):
> -        raise error.Abort(_('SMTPS requires Python 2.6 or later'))
> +    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'''
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -70,31 +70,27 @@ 
             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.
+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
+    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
-else:
-    def SMTPS(sslkwargs, keyfile=None, certfile=None, **kwargs):
-        raise error.Abort(_('SMTPS requires Python 2.6 or later'))
+    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'''