[Python-checkins] r65152 - python/trunk/Lib/asyncore.py

georg.brandl python-checkins at python.org
Sun Jul 20 09:29:58 CEST 2008


Author: georg.brandl
Date: Sun Jul 20 09:29:58 2008
New Revision: 65152

Log:
Remove exception indexing in asyncore.


Modified:
   python/trunk/Lib/asyncore.py

Modified: python/trunk/Lib/asyncore.py
==============================================================================
--- python/trunk/Lib/asyncore.py	(original)
+++ python/trunk/Lib/asyncore.py	Sun Jul 20 09:29:58 2008
@@ -129,7 +129,7 @@
         try:
             r, w, e = select.select(r, w, e, timeout)
         except select.error, err:
-            if err[0] != EINTR:
+            if err.args[0] != EINTR:
                 raise
             else:
                 return
@@ -175,7 +175,7 @@
         try:
             r = pollster.poll(timeout)
         except select.error, err:
-            if err[0] != EINTR:
+            if err.args[0] != EINTR:
                 raise
             r = []
         for fd, flags in r:
@@ -231,7 +231,7 @@
             try:
                 self.addr = sock.getpeername()
             except socket.error, err:
-                if err[0] == ENOTCONN:
+                if err.args[0] == ENOTCONN:
                     # To handle the case where we got an unconnected
                     # socket.
                     self.connected = False
@@ -339,7 +339,7 @@
             conn, addr = self.socket.accept()
             return conn, addr
         except socket.error, why:
-            if why[0] == EWOULDBLOCK:
+            if why.args[0] == EWOULDBLOCK:
                 pass
             else:
                 raise
@@ -349,9 +349,9 @@
             result = self.socket.send(data)
             return result
         except socket.error, why:
-            if why[0] == EWOULDBLOCK:
+            if why.args[0] == EWOULDBLOCK:
                 return 0
-            elif why[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
+            elif why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
                 self.handle_close()
                 return 0
             else:
@@ -369,7 +369,7 @@
                 return data
         except socket.error, why:
             # winsock sometimes throws ENOTCONN
-            if why[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED]:
+            if why.args[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED]:
                 self.handle_close()
                 return ''
             else:
@@ -382,7 +382,7 @@
         try:
             self.socket.close()
         except socket.error, why:
-            if why[0] not in (ENOTCONN, EBADF):
+            if why.args[0] not in (ENOTCONN, EBADF):
                 raise
 
     # cheap inheritance, used to pass all other attribute
@@ -549,7 +549,7 @@
         try:
             x.close()
         except OSError, x:
-            if x[0] == EBADF:
+            if x.args[0] == EBADF:
                 pass
             elif not ignore_all:
                 raise


More information about the Python-checkins mailing list