Browse Source

[2300] use _master_addrinfo[0] for address family in _get_ipver_str()

Because _get_ipver_str() is referring to an attribute of NoneType when it is
invoked earlier than init_socket() and when the socket object is None.
Naoki Kambe 12 years ago
parent
commit
f7a34944f3
2 changed files with 2 additions and 4 deletions
  1. 0 2
      src/bin/xfrin/tests/xfrin_test.py
  2. 2 2
      src/bin/xfrin/xfrin.py.in

+ 0 - 2
src/bin/xfrin/tests/xfrin_test.py

@@ -1105,12 +1105,10 @@ class TestAXFR(TestXfrinConnection):
         for (info, ver) in addrs:
             c = MockXfrinConnection({}, TEST_ZONE_NAME, RRClass.CH, None,
                                     threading.Event(), info)
-            c.init_socket()
             if ver is not None:
                 self.assertEqual(ver, c._get_ipver_str())
             else:
                 self.assertRaises(ValueError, c._get_ipver_str)
-            c.close()
 
     def test_soacheck(self):
         # we need to defer the creation until we know the QID, which is

+ 2 - 2
src/bin/xfrin/xfrin.py.in

@@ -860,9 +860,9 @@ class XfrinConnection(asyncore.dispatcher):
         It raises a ValueError exception on other address families.
 
         """
-        if self.socket.family == socket.AF_INET:
+        if self._master_addrinfo[0] == socket.AF_INET:
             return 'v4'
-        elif self.socket.family == socket.AF_INET6:
+        elif self._master_addrinfo[0] == socket.AF_INET6:
             return 'v6'
         raise ValueError("Invalid address family. "
                          "This is supported only for IP sockets")