]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #13895: fix test_ssl hanging under Ubuntu
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 28 Jan 2012 16:38:34 +0000 (17:38 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 28 Jan 2012 16:38:34 +0000 (17:38 +0100)
Lib/test/test_ssl.py

index bde42888e330278203a5dd082a6b83b721d717f4..1b08f2e7dc4cfbfce939c9bdab041d2de90d6f09 100644 (file)
@@ -1078,28 +1078,28 @@ else:
                                     chatty=chatty,
                                     connectionchatty=False)
         with server:
-            s = client_context.wrap_socket(socket.socket())
-            s.connect((HOST, server.port))
-            for arg in [indata, bytearray(indata), memoryview(indata)]:
-                if connectionchatty:
-                    if support.verbose:
-                        sys.stdout.write(
-                            " client:  sending %r...\n" % indata)
-                s.write(arg)
-                outdata = s.read()
+            with client_context.wrap_socket(socket.socket()) as s:
+                s.connect((HOST, server.port))
+                for arg in [indata, bytearray(indata), memoryview(indata)]:
+                    if connectionchatty:
+                        if support.verbose:
+                            sys.stdout.write(
+                                " client:  sending %r...\n" % indata)
+                    s.write(arg)
+                    outdata = s.read()
+                    if connectionchatty:
+                        if support.verbose:
+                            sys.stdout.write(" client:  read %r\n" % outdata)
+                    if outdata != indata.lower():
+                        raise AssertionError(
+                            "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
+                            % (outdata[:20], len(outdata),
+                               indata[:20].lower(), len(indata)))
+                s.write(b"over\n")
                 if connectionchatty:
                     if support.verbose:
-                        sys.stdout.write(" client:  read %r\n" % outdata)
-                if outdata != indata.lower():
-                    raise AssertionError(
-                        "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
-                        % (outdata[:20], len(outdata),
-                           indata[:20].lower(), len(indata)))
-            s.write(b"over\n")
-            if connectionchatty:
-                if support.verbose:
-                    sys.stdout.write(" client:  closing connection.\n")
-            s.close()
+                        sys.stdout.write(" client:  closing connection.\n")
+                s.close()
 
     def try_protocol_combo(server_protocol, client_protocol, expect_success,
                            certsreqs=None, server_options=0, client_options=0):