@@ -113,7 +113,7 @@ def readwrite(obj, flags):
113113 if flags & (select .POLLHUP | select .POLLERR | select .POLLNVAL ):
114114 obj .handle_close ()
115115 except OSError as e :
116- if e .args [ 0 ] not in _DISCONNECTED :
116+ if e .errno not in _DISCONNECTED :
117117 obj .handle_error ()
118118 else :
119119 obj .handle_close ()
@@ -236,7 +236,7 @@ def __init__(self, sock=None, map=None):
236236 try :
237237 self .addr = sock .getpeername ()
238238 except OSError as err :
239- if err .args [ 0 ] in (ENOTCONN , EINVAL ):
239+ if err .errno in (ENOTCONN , EINVAL ):
240240 # To handle the case where we got an unconnected
241241 # socket.
242242 self .connected = False
@@ -346,7 +346,7 @@ def accept(self):
346346 except TypeError :
347347 return None
348348 except OSError as why :
349- if why .args [ 0 ] in (EWOULDBLOCK , ECONNABORTED , EAGAIN ):
349+ if why .errno in (EWOULDBLOCK , ECONNABORTED , EAGAIN ):
350350 return None
351351 else :
352352 raise
@@ -358,9 +358,9 @@ def send(self, data):
358358 result = self .socket .send (data )
359359 return result
360360 except OSError as why :
361- if why .args [ 0 ] == EWOULDBLOCK :
361+ if why .errno == EWOULDBLOCK :
362362 return 0
363- elif why .args [ 0 ] in _DISCONNECTED :
363+ elif why .errno in _DISCONNECTED :
364364 self .handle_close ()
365365 return 0
366366 else :
@@ -378,7 +378,7 @@ def recv(self, buffer_size):
378378 return data
379379 except OSError as why :
380380 # winsock sometimes raises ENOTCONN
381- if why .args [ 0 ] in _DISCONNECTED :
381+ if why .errno in _DISCONNECTED :
382382 self .handle_close ()
383383 return b''
384384 else :
@@ -393,7 +393,7 @@ def close(self):
393393 try :
394394 self .socket .close ()
395395 except OSError as why :
396- if why .args [ 0 ] not in (ENOTCONN , EBADF ):
396+ if why .errno not in (ENOTCONN , EBADF ):
397397 raise
398398
399399 # log and log_info may be overridden to provide more sophisticated
@@ -557,7 +557,7 @@ def close_all(map=None, ignore_all=False):
557557 try :
558558 x .close ()
559559 except OSError as x :
560- if x .args [ 0 ] == EBADF :
560+ if x .errno == EBADF :
561561 pass
562562 elif not ignore_all :
563563 raise
0 commit comments