[Python-checkins] cpython: Issue #12136: Added change to handle non-availability of the ssl module.

vinay.sajip python-checkins at python.org
Sat May 21 17:46:48 CEST 2011


http://hg.python.org/cpython/rev/2be3ffa82293
changeset:   70254:2be3ffa82293
parent:      70247:897372653bef
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Sat May 21 16:46:41 2011 +0100
summary:
  Issue #12136: Added change to handle non-availability of the ssl module.

files:
  Lib/test/test_logging.py |  23 ++++++++++++++---------
  1 files changed, 14 insertions(+), 9 deletions(-)


diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1526,14 +1526,17 @@
         for secure in (False, True):
             addr = ('localhost', 0)
             if secure:
-                import ssl
-                fd, fn = tempfile.mkstemp()
-                os.close(fd)
-                with open(fn, 'w') as f:
-                    f.write(self.PEMFILE)
-                sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
-                sslctx.load_cert_chain(fn)
-                os.unlink(fn)
+                try:
+                    import ssl
+                    fd, fn = tempfile.mkstemp()
+                    os.close(fd)
+                    with open(fn, 'w') as f:
+                        f.write(self.PEMFILE)
+                    sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+                    sslctx.load_cert_chain(fn)
+                    os.unlink(fn)
+                except ImportError:
+                    sslctx = None
             else:
                 sslctx = None
             self.server = server = TestHTTPServer(addr, self.handle_request,
@@ -1541,7 +1544,9 @@
             server.start()
             server.ready.wait()
             host = 'localhost:%d' % server.server_port
-            self.h_hdlr = logging.handlers.HTTPHandler(host, '/frob', secure=secure)
+            secure_client = secure and sslctx
+            self.h_hdlr = logging.handlers.HTTPHandler(host, '/frob',
+                                                       secure=secure_client)
             self.log_data = None
             root_logger.addHandler(self.h_hdlr)
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list