Patchwork sslutil: remove conditional cipher code needed for Python 2.6

login
register
mail settings
Submitter Gregory Szorc
Date May 11, 2017, 6:32 a.m.
Message ID <c277c388f639a12de900.1494484354@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20566/
State Accepted
Headers show

Comments

Gregory Szorc - May 11, 2017, 6:32 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1494484320 25200
#      Wed May 10 23:32:00 2017 -0700
# Node ID c277c388f639a12de90093897f8e3471c59cf1e7
# Parent  1ada3d18e7fbc9069910f2c036992d2f2b28e058
sslutil: remove conditional cipher code needed for Python 2.6

We dropped support for Python 2.6. So this code to work around a
missing feature on 2.6 is no longer necessary.
Augie Fackler - May 13, 2017, 2:08 a.m.
On Wed, May 10, 2017 at 11:32:34PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1494484320 25200
> #      Wed May 10 23:32:00 2017 -0700
> # Node ID c277c388f639a12de90093897f8e3471c59cf1e7
> # Parent  1ada3d18e7fbc9069910f2c036992d2f2b28e058
> sslutil: remove conditional cipher code needed for Python 2.6

queued, thanks

Patch

diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py
--- a/mercurial/sslutil.py
+++ b/mercurial/sslutil.py
@@ -13,7 +13,6 @@  import hashlib
 import os
 import re
 import ssl
-import sys
 
 from .i18n import _
 from . import (
@@ -58,9 +57,6 @@  except AttributeError:
 
     # We implement SSLContext using the interface from the standard library.
     class SSLContext(object):
-        # ssl.wrap_socket gained the "ciphers" named argument in 2.7.
-        _supportsciphers = sys.version_info >= (2, 7)
-
         def __init__(self, protocol):
             # From the public interface of SSLContext
             self.protocol = protocol
@@ -92,13 +88,6 @@  except AttributeError:
             self._cacerts = cafile
 
         def set_ciphers(self, ciphers):
-            if not self._supportsciphers:
-                raise error.Abort(_('setting ciphers in [hostsecurity] is not '
-                                    'supported by this version of Python'),
-                                  hint=_('remove the config option or run '
-                                         'Mercurial with a modern Python '
-                                         'version (preferred)'))
-
             self._ciphers = ciphers
 
         def wrap_socket(self, socket, server_hostname=None, server_side=False):
@@ -113,11 +102,9 @@  except AttributeError:
                 'cert_reqs': self.verify_mode,
                 'ssl_version': self.protocol,
                 'ca_certs': self._cacerts,
+                'ciphers': self._ciphers,
             }
 
-            if self._supportsciphers:
-                args['ciphers'] = self._ciphers
-
             return ssl.wrap_socket(socket, **args)
 
 def _hostsettings(ui, hostname):