From 8bafc646cb2efe1cfd8cabff8507dd539ac6f22b Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 5 Sep 2014 13:48:45 -0500 Subject: [PATCH] Disable custom https handler for fetch_url on older pythons Fixes #8898 --- lib/ansible/module_utils/urls.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py index ab26b9eb1c3..07d6c906272 100644 --- a/lib/ansible/module_utils/urls.py +++ b/lib/ansible/module_utils/urls.py @@ -396,7 +396,10 @@ def fetch_url(module, url, data=None, headers=None, method=None, proxyhandler = urllib2.ProxyHandler({}) handlers.append(proxyhandler) - handlers.append(CustomHTTPSHandler) + # pre-2.6 versions of python cannot use the custom https + # handler, since the socket class is lacking this method + if hasattr(socket, 'create_connection'): + handlers.append(CustomHTTPSHandler) opener = urllib2.build_opener(*handlers) urllib2.install_opener(opener)