[Python-checkins] r86565 - in python/branches/py3k: Lib/test/test_socket.py Misc/NEWS

georg.brandl python-checkins at python.org
Sat Nov 20 15:16:18 CET 2010


Author: georg.brandl
Date: Sat Nov 20 15:16:17 2010
New Revision: 86565

Log:
socket.gethostbyname(socket.gethostname()) can fail when host name resolution is not set up correctly; do not fail test_socket if this is the case.

Modified:
   python/branches/py3k/Lib/test/test_socket.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/test/test_socket.py
==============================================================================
--- python/branches/py3k/Lib/test/test_socket.py	(original)
+++ python/branches/py3k/Lib/test/test_socket.py	Sat Nov 20 15:16:17 2010
@@ -544,7 +544,11 @@
         # XXX(nnorwitz): http://tinyurl.com/os5jz seems to indicate
         # it reasonable to get the host's addr in addition to 0.0.0.0.
         # At least for eCos.  This is required for the S/390 to pass.
-        my_ip_addr = socket.gethostbyname(socket.gethostname())
+        try:
+            my_ip_addr = socket.gethostbyname(socket.gethostname())
+        except socket.error:
+            # Probably name lookup wasn't set up right; skip this test
+            return
         self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
         self.assertEqual(name[1], port)
 

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Nov 20 15:16:17 2010
@@ -46,6 +46,9 @@
 Tests
 -----
 
+- Do not fail test_socket when the IP address of the local hostname
+  cannot be looked up.
+
 - Issue #8886: Use context managers throughout test_zipfile. Patch by
   Eric Carstensen.
 


More information about the Python-checkins mailing list