Tighten exceptions for new sockets and reads
authorJeremy Stanley <fungi@yuggoth.org>
Thu, 27 Mar 2014 10:51:17 +0000 (10:51 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Thu, 27 Mar 2014 10:51:17 +0000 (10:51 +0000)
* lib/mudpy/misc.py(User.enqueue_input,check_for_connection): When
reading from a socket or polling for a new connection, be specific about
the exceptions which are benign so that we will still error out when
more detrimental exceptions are raised.

lib/mudpy/misc.py

index ed48769..7e8e612 100644 (file)
@@ -907,7 +907,7 @@ class User:
         # check for some input
         try:
             raw_input = self.connection.recv(1024)
-        except:
+        except (BlockingIOError, OSError):
             raw_input = b""
 
         # we got something
@@ -1489,7 +1489,7 @@ def check_for_connection(listening_socket):
     # try to accept a new connection
     try:
         connection, address = listening_socket.accept()
-    except:
+    except BlockingIOError:
         return None
 
     # note that we got one