summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart McLaren <stuart.mclaren@hp.com>2015-04-11 10:28:20 +0000
committerStuart McLaren <stuart.mclaren@hp.com>2015-04-11 11:04:23 +0000
commitbd0aa0672e0ebb5dfaa2178a8ffce79be143524b (patch)
tree696ad83fb27b6b3b665e74d63bb6451a233f02f4
parentc698b4e3227b4767f042e435423fcc307d7f6d5c (diff)
downloadpython-glanceclient-bd0aa0672e0ebb5dfaa2178a8ffce79be143524b.tar.gz
Fix https stack trace on python 3.4 client
When using the client with python 3.4 and no ssl compression the following stack trace ocurrs: TypeError: startswith first arg must be bytes or a tuple of bytes, not str Closes-bug: 1442883 Related-bug: 1357430 Change-Id: I8e28f0bb1f3e866f11851247ce31470ca8c2af4f
-rw-r--r--glanceclient/common/https.py4
-rw-r--r--tests/test_ssl.py7
2 files changed, 3 insertions, 8 deletions
diff --git a/glanceclient/common/https.py b/glanceclient/common/https.py
index 51f8f6d..649d14b 100644
--- a/glanceclient/common/https.py
+++ b/glanceclient/common/https.py
@@ -158,7 +158,9 @@ class HTTPSAdapter(adapters.HTTPAdapter):
# NOTE(flaper87): Make sure the url is encoded, otherwise
# python's standard httplib will fail with a TypeError.
url = super(HTTPSAdapter, self).request_url(request, proxies)
- return encodeutils.safe_encode(url)
+ if six.PY2:
+ url = encodeutils.safe_encode(url)
+ return url
def _create_glance_httpsconnectionpool(self, url):
kw = self.poolmanager.connection_kw
diff --git a/tests/test_ssl.py b/tests/test_ssl.py
index cdfff5e..907b7bf 100644
--- a/tests/test_ssl.py
+++ b/tests/test_ssl.py
@@ -84,11 +84,6 @@ class TestHTTPSVerifyCert(testtools.TestCase):
server_thread.daemon = True
server_thread.start()
- def _skip_python3(self):
- if six.PY3:
- msg = ("Skipping: python3 for now. Requires bugfix.")
- self.skipTest(msg)
-
def test_v1_requests_cert_verification(self):
"""v1 regression test for bug 115260."""
port = self.port
@@ -108,7 +103,6 @@ class TestHTTPSVerifyCert(testtools.TestCase):
def test_v1_requests_cert_verification_no_compression(self):
"""v1 regression test for bug 115260."""
- self._skip_python3()
port = self.port
url = 'https://0.0.0.0:%d' % port
@@ -143,7 +137,6 @@ class TestHTTPSVerifyCert(testtools.TestCase):
def test_v2_requests_cert_verification_no_compression(self):
"""v2 regression test for bug 115260."""
- self._skip_python3()
port = self.port
url = 'https://0.0.0.0:%d' % port