File python3-apache-libcloud-ssl_match_hostname.patch of Package python3-apache-libcloud

diff --git a/libcloud/httplib_ssl.py b/libcloud/httplib_ssl.py
index 52d1ed1..bd65656 100644
--- a/libcloud/httplib_ssl.py
+++ b/libcloud/httplib_ssl.py
@@ -23,13 +23,13 @@
 import base64
 import warnings
 
-from backports.ssl_match_hostname import match_hostname, CertificateError
-
 import libcloud.security
 from libcloud.utils.py3 import b
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
 from libcloud.utils.py3 import urlunquote
+from libcloud.utils.py3 import match_hostname
+from libcloud.utils.py3 import CertificateError
 
 
 __all__ = [
diff --git a/libcloud/utils/py3.py b/libcloud/utils/py3.py
index 2b695a4..7ef3c8b 100644
--- a/libcloud/utils/py3.py
+++ b/libcloud/utils/py3.py
@@ -53,6 +53,13 @@
 if sys.version_info >= (3, 2) and sys.version_info < (3, 3):
     PY32 = True
 
+if sys.version_info >= (3, 2):
+    # ssl module in Python >= 3.2 includes match hostname function
+    from ssl import match_hostname, CertificateError  # NOQA
+else:
+    from backports.ssl_match_hostname import match_hostname, CertificateError  # NOQA
+
+
 if PY3:
     import http.client as httplib
     from io import StringIO
diff --git a/setup.py b/setup.py
index 63e9ce7..23049fb 100644
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,6 @@
 
 import libcloud.utils.misc
 from libcloud.utils.dist import get_packages, get_data_files
-from libcloud.utils.py3 import unittest2_required
 
 libcloud.utils.misc.SHOW_DEPRECATION_WARNING = False
 
@@ -47,10 +46,19 @@
 SUPPORTED_VERSIONS = ['2.5', '2.6', '2.7', 'PyPy', '3.x']
 
 TEST_REQUIREMENTS = [
-    'backports.ssl_match_hostname',
     'mock'
 ]
 
+if sys.version_info < (3, 2):
+    TEST_REQUIREMENTS.append('backports.ssl_match_hostname')
+
+# Note: we cant use libcloud.utils.py3 here because it relies on backports
+# dependency on being available
+if sys.version_info >= (2, 7):
+    unittest2_required = False
+else:
+    unittest2_required = True
+
 if sys.version_info <= (2, 4):
     version = '.'.join([str(x) for x in sys.version_info[:3]])
     print('Version ' + version + ' is not supported. Supported versions are ' +
@@ -222,10 +230,13 @@ def run(self):
 
 forbid_publish()
 
-install_requires = ['backports.ssl_match_hostname']
+install_requires = []
 if pre_python26:
     install_requires.extend(['ssl', 'simplejson'])
 
+if sys.version_info < (3, 2):
+    install_requires.append('backports.ssl_match_hostname')
+
 setup(
     name='apache-libcloud',
     version=read_version_string(),
diff --git a/tox.ini b/tox.ini
index d081603..e612f5f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -29,20 +29,17 @@ deps = backports.ssl_match_hostname
        lockfile
 
 [testenv:py32]
-deps = backports.ssl_match_hostname
-       mock
+deps = mock
        lockfile
 
 [testenv:py33]
-deps = backports.ssl_match_hostname
-       mock
+deps = mock
        lockfile
 
 [testenv:py34]
 # At some point we can switch to use the stdlib provided mock module on
 # Python3.4+
-deps = backports.ssl_match_hostname
-       mock
+deps = mock
        lockfile
 
 [testenv:docs]
openSUSE Build Service is sponsored by