[PATCH] sslutil: remove conditional cipher code needed for Python 2.6

Gregory Szorc gregory.szorc at gmail.com
Thu May 11 06:32:34 UTC 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at 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.

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):


More information about the Mercurial-devel mailing list