diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-11-22 08:28:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-22 08:28:34 (GMT) |
commit | c4d45ee670c09d4f6da709df072ec80cb7dfad22 (patch) | |
tree | ffa3ba91afd9e93b19ada3967236529a6c1b3fd9 /Lib/asyncore.py | |
parent | bd8c22e1fa8f8f6e31ee083a8b9321a2c324f02f (diff) | |
download | cpython-c4d45ee670c09d4f6da709df072ec80cb7dfad22.zip cpython-c4d45ee670c09d4f6da709df072ec80cb7dfad22.tar.gz cpython-c4d45ee670c09d4f6da709df072ec80cb7dfad22.tar.bz2 |
bpo-42427: Use the errno attribute of OSError instead of args[0] (GH-23449)
Diffstat (limited to 'Lib/asyncore.py')
-rw-r--r-- | Lib/asyncore.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py index ce16f11..eeea488 100644 --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -113,7 +113,7 @@ def readwrite(obj, flags): if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL): obj.handle_close() except OSError as e: - if e.args[0] not in _DISCONNECTED: + if e.errno not in _DISCONNECTED: obj.handle_error() else: obj.handle_close() @@ -236,7 +236,7 @@ class dispatcher: try: self.addr = sock.getpeername() except OSError as err: - if err.args[0] in (ENOTCONN, EINVAL): + if err.errno in (ENOTCONN, EINVAL): # To handle the case where we got an unconnected # socket. self.connected = False @@ -346,7 +346,7 @@ class dispatcher: except TypeError: return None except OSError as why: - if why.args[0] in (EWOULDBLOCK, ECONNABORTED, EAGAIN): + if why.errno in (EWOULDBLOCK, ECONNABORTED, EAGAIN): return None else: raise @@ -358,9 +358,9 @@ class dispatcher: result = self.socket.send(data) return result except OSError as why: - if why.args[0] == EWOULDBLOCK: + if why.errno == EWOULDBLOCK: return 0 - elif why.args[0] in _DISCONNECTED: + elif why.errno in _DISCONNECTED: self.handle_close() return 0 else: @@ -378,7 +378,7 @@ class dispatcher: return data except OSError as why: # winsock sometimes raises ENOTCONN - if why.args[0] in _DISCONNECTED: + if why.errno in _DISCONNECTED: self.handle_close() return b'' else: @@ -393,7 +393,7 @@ class dispatcher: try: self.socket.close() except OSError as why: - if why.args[0] not in (ENOTCONN, EBADF): + if why.errno not in (ENOTCONN, EBADF): raise # log and log_info may be overridden to provide more sophisticated @@ -557,7 +557,7 @@ def close_all(map=None, ignore_all=False): try: x.close() except OSError as x: - if x.args[0] == EBADF: + if x.errno == EBADF: pass elif not ignore_all: raise |