[Python-checkins] r84604 - python/branches/py3k/Lib/test/support.py

antoine.pitrou python-checkins at python.org
Tue Sep 7 23:43:31 CEST 2010


Author: antoine.pitrou
Date: Tue Sep  7 23:43:31 2010
New Revision: 84604

Log:
Also catch some gaierrors



Modified:
   python/branches/py3k/Lib/test/support.py

Modified: python/branches/py3k/Lib/test/support.py
==============================================================================
--- python/branches/py3k/Lib/test/support.py	(original)
+++ python/branches/py3k/Lib/test/support.py	Tue Sep  7 23:43:31 2010
@@ -793,16 +793,25 @@
         ('ENETUNREACH', 101),
         ('ETIMEDOUT', 110),
     ]
+    default_gai_errnos = [
+        ('EAI_NONAME', -2),
+        ('EAI_NODATA', -5),
+    ]
 
     denied = ResourceDenied("Resource '%s' is not available" % resource_name)
     captured_errnos = errnos
+    gai_errnos = []
     if not captured_errnos:
         captured_errnos = [getattr(errno, name, num)
                            for (name, num) in default_errnos]
+        gai_errnos = [getattr(socket, name, num)
+                      for (name, num) in default_gai_errnos]
 
     def filter_error(err):
+        n = getattr(err, 'errno', None)
         if (isinstance(err, socket.timeout) or
-            getattr(err, 'errno', None) in captured_errnos):
+            (isinstance(err, socket.gaierror) and n in gai_errnos) or
+            n in captured_errnos):
             if not verbose:
                 sys.stderr.write(denied.args[0] + "\n")
             raise denied from err


More information about the Python-checkins mailing list