GeezerVison is showing github.com — bpo-42427: Use the errno attribute of OSError instead of args[0] (GH-… · python/cpython@c4d45ee
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Lib/asyncore.py +8-8Lines changed: 8 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -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 | |
Collapse file Copy file name to clipboardExpand all lines: Lib/smtpd.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -163,7 +163,7 @@ def __init__(self, server, conn, addr, data_size_limit=DATA_SIZE_DEFAULT, | 163 | 163 | # a race condition may occur if the other end is closing | 164 | 164 | # before we can get the peername | 165 | 165 | self.close() | 166 | | - if err.args[0] != errno.ENOTCONN: | | 166 | + if err.errno != errno.ENOTCONN: | 167 | 167 | raise | 168 | 168 | return | 169 | 169 | print('Peer:', repr(self.peer), file=DEBUGSTREAM) | |
Collapse file Copy file name to clipboardExpand all lines: Lib/socket.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -706,7 +706,7 @@ def readinto(self, b): | 706 | 706 | self._timeout_occurred = True | 707 | 707 | raise | 708 | 708 | except error as e: | 709 | | - if e.args[0] in _blocking_errnos: | | 709 | + if e.errno in _blocking_errnos: | 710 | 710 | return None | 711 | 711 | raise | 712 | 712 |
| @@ -722,7 +722,7 @@ def write(self, b): | 722 | 722 | return self._sock.send(b) | 723 | 723 | except error as e: | 724 | 724 | # XXX what about EINTR? | 725 | | - if e.args[0] in _blocking_errnos: | | 725 | + if e.errno in _blocking_errnos: | 726 | 726 | return None | 727 | 727 | raise | 728 | 728 |
| |
|