From 7bd9afea1ee20aa33622aedf0f3a5375036fbabf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 9 Aug 2018 22:40:55 +0200
Subject: [PATCH] Support old Python 2.7 releases (#341)

See https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459
---
 httpretty/core.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/httpretty/core.py b/httpretty/core.py
index 6e89634..92dd8a9 100644
--- a/httpretty/core.py
+++ b/httpretty/core.py
@@ -99,7 +99,10 @@ except ImportError:
 try:  # pragma: no cover
     import ssl
     old_ssl_wrap_socket = ssl.wrap_socket
-    old_sslcontext_wrap_socket = ssl.SSLContext.wrap_socket
+    try:
+        old_sslcontext_wrap_socket = ssl.SSLContext.wrap_socket
+    except AttributeError:
+        pass
     if not PY3:
         old_sslwrap_simple = ssl.sslwrap_simple
     old_sslsocket = ssl.SSLSocket
@@ -1397,7 +1400,10 @@ class httpretty(HttpBaseClass):
         if ssl:
             ssl.wrap_socket = old_ssl_wrap_socket
             ssl.SSLSocket = old_sslsocket
-            ssl.SSLContext.wrap_socket = old_sslcontext_wrap_socket
+            try:
+                ssl.SSLContext.wrap_socket = old_sslcontext_wrap_socket
+            except AttributeError:
+                pass
             ssl.__dict__['wrap_socket'] = old_ssl_wrap_socket
             ssl.__dict__['SSLSocket'] = old_sslsocket
 
@@ -1488,7 +1494,10 @@ class httpretty(HttpBaseClass):
             new_wrap = partial(fake_wrap_socket, old_ssl_wrap_socket)
             ssl.wrap_socket = new_wrap
             ssl.SSLSocket = FakeSSLSocket
-            ssl.SSLContext.wrap_socket = partial(fake_wrap_socket, old_sslcontext_wrap_socket)
+            try:
+                ssl.SSLContext.wrap_socket = partial(fake_wrap_socket, old_sslcontext_wrap_socket)
+            except AttributeError:
+                pass
 
             ssl.__dict__['wrap_socket'] = new_wrap
             ssl.__dict__['SSLSocket'] = FakeSSLSocket
-- 
2.39.0.windows.2

