@@ -113,7 +113,7 @@ def readwrite(obj, flags):
113
113
if flags & (select .POLLHUP | select .POLLERR | select .POLLNVAL ):
114
114
obj .handle_close ()
115
115
except OSError as e :
116
- if e .args [ 0 ] not in _DISCONNECTED :
116
+ if e .errno not in _DISCONNECTED :
117
117
obj .handle_error ()
118
118
else :
119
119
obj .handle_close ()
@@ -236,7 +236,7 @@ def __init__(self, sock=None, map=None):
236
236
try :
237
237
self .addr = sock .getpeername ()
238
238
except OSError as err :
239
- if err .args [ 0 ] in (ENOTCONN , EINVAL ):
239
+ if err .errno in (ENOTCONN , EINVAL ):
240
240
# To handle the case where we got an unconnected
241
241
# socket.
242
242
self .connected = False
@@ -346,7 +346,7 @@ def accept(self):
346
346
except TypeError :
347
347
return None
348
348
except OSError as why :
349
- if why .args [ 0 ] in (EWOULDBLOCK , ECONNABORTED , EAGAIN ):
349
+ if why .errno in (EWOULDBLOCK , ECONNABORTED , EAGAIN ):
350
350
return None
351
351
else :
352
352
raise
@@ -358,9 +358,9 @@ def send(self, data):
358
358
result = self .socket .send (data )
359
359
return result
360
360
except OSError as why :
361
- if why .args [ 0 ] == EWOULDBLOCK :
361
+ if why .errno == EWOULDBLOCK :
362
362
return 0
363
- elif why .args [ 0 ] in _DISCONNECTED :
363
+ elif why .errno in _DISCONNECTED :
364
364
self .handle_close ()
365
365
return 0
366
366
else :
@@ -378,7 +378,7 @@ def recv(self, buffer_size):
378
378
return data
379
379
except OSError as why :
380
380
# winsock sometimes raises ENOTCONN
381
- if why .args [ 0 ] in _DISCONNECTED :
381
+ if why .errno in _DISCONNECTED :
382
382
self .handle_close ()
383
383
return b''
384
384
else :
@@ -393,7 +393,7 @@ def close(self):
393
393
try :
394
394
self .socket .close ()
395
395
except OSError as why :
396
- if why .args [ 0 ] not in (ENOTCONN , EBADF ):
396
+ if why .errno not in (ENOTCONN , EBADF ):
397
397
raise
398
398
399
399
# log and log_info may be overridden to provide more sophisticated
@@ -557,7 +557,7 @@ def close_all(map=None, ignore_all=False):
557
557
try :
558
558
x .close ()
559
559
except OSError as x :
560
- if x .args [ 0 ] == EBADF :
560
+ if x .errno == EBADF :
561
561
pass
562
562
elif not ignore_all :
563
563
raise
0 commit comments