BIND 10 master, updated. 26f8bf358b2eceec472e341f1f380bf9474913de [master] avoid using 'with' protocol for socket.socket. it doesn't work < 3.2.

BIND 10 source code commits bind10-changes at lists.isc.org
Fri May 24 05:39:21 UTC 2013


The branch, master has been updated
       via  26f8bf358b2eceec472e341f1f380bf9474913de (commit)
      from  4eb6ec7a740b1ec21334cc69b0272883c8e874cf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 26f8bf358b2eceec472e341f1f380bf9474913de
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Thu May 23 22:38:17 2013 -0700

    [master] avoid using 'with' protocol for socket.socket. it doesn't work < 3.2.
    
    this should fix test failures reported by buildbots.  confirmed, committing
    at my discretion.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/xfrout/tests/xfrout_test.py.in |   25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/xfrout/tests/xfrout_test.py.in b/src/bin/xfrout/tests/xfrout_test.py.in
index 5141844..7c71e78 100644
--- a/src/bin/xfrout/tests/xfrout_test.py.in
+++ b/src/bin/xfrout/tests/xfrout_test.py.in
@@ -199,16 +199,21 @@ class TestUtility(unittest.TestCase):
         def is_blocking(fd):
             return (fcntl.fcntl(fd, fcntl.F_GETFL) & os.O_NONBLOCK) == 0
 
-        with socket.socket(socket.AF_INET, socket.SOCK_STREAM,
-                           socket.IPPROTO_TCP) as sock:
-            # By default socket is made blocking
-            self.assertTrue(is_blocking(sock.fileno()))
-            # make_blocking(False) makes it non blocking
-            xfrout.make_blocking(sock.fileno(), False)
-            self.assertFalse(is_blocking(sock.fileno()))
-            # make_blocking(True) makes it blocking again
-            xfrout.make_blocking(sock.fileno(), True)
-            self.assertTrue(is_blocking(sock.fileno()))
+        # socket.socket doesn't support the 'with' statement before Python
+        # 3.2, so we'll close it ourselves (while it's not completely exception
+        # safe, it should be acceptable for a test case)
+        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM,
+                             socket.IPPROTO_TCP)
+        # By default socket is made blocking
+        self.assertTrue(is_blocking(sock.fileno()))
+        # make_blocking(False) makes it non blocking
+        xfrout.make_blocking(sock.fileno(), False)
+        self.assertFalse(is_blocking(sock.fileno()))
+        # make_blocking(True) makes it blocking again
+        xfrout.make_blocking(sock.fileno(), True)
+        self.assertTrue(is_blocking(sock.fileno()))
+
+        sock.close()
 
 class TestXfroutSessionBase(unittest.TestCase):
     '''Base class for tests related to xfrout sessions



More information about the bind10-changes mailing list