]> granicus.if.org Git - python/commitdiff
Try to handle socket.errors properly in is_unavailable
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 27 Jan 2008 18:19:04 +0000 (18:19 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 27 Jan 2008 18:19:04 +0000 (18:19 +0000)
Lib/test/test_xmlrpc.py

index 17d7a7a134fc09dc5557a1954b1bc903ddf5ebd5..70a6b39f6892a884fb25dfdfd5625f7964950967 100644 (file)
@@ -348,10 +348,14 @@ def is_unavailable_exception(e):
        given by operations on non-blocking sockets.'''
 
     # sometimes we get a -1 error code and/or empty headers
-    if e.errcode == -1 or e.headers is None:
-        return True
+    try:
+        if e.errcode == -1 or e.headers is None:
+            return True
+        exc_mess = e.headers.get('X-exception')
+    except AttributeError:
+        # Ignore socket.errors here.
+        exc_mess = str(e)
 
-    exc_mess = e.headers.get('X-exception')
     if exc_mess and 'temporarily unavailable' in exc_mess.lower():
         return True