GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-42427: Use the errno attribute of OSError instead of args[0] (GH-… · python/cpython@c4d45ee

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib
    • asyncore.py
    • smtpd.py
    • socket.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/asyncore.py‎

Copy file name to clipboardExpand all lines: Lib/asyncore.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Collapse file

‎Lib/smtpd.py‎

Copy file name to clipboardExpand all lines: Lib/smtpd.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def __init__(self, server, conn, addr, data_size_limit=DATA_SIZE_DEFAULT,
163163
# a race condition may occur if the other end is closing
164164
# before we can get the peername
165165
self.close()
166-
if err.args[0] != errno.ENOTCONN:
166+
if err.errno != errno.ENOTCONN:
167167
raise
168168
return
169169
print('Peer:', repr(self.peer), file=DEBUGSTREAM)
Collapse file

‎Lib/socket.py‎

Copy file name to clipboardExpand all lines: Lib/socket.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def readinto(self, b):
706706
self._timeout_occurred = True
707707
raise
708708
except error as e:
709-
if e.args[0] in _blocking_errnos:
709+
if e.errno in _blocking_errnos:
710710
return None
711711
raise
712712

@@ -722,7 +722,7 @@ def write(self, b):
722722
return self._sock.send(b)
723723
except error as e:
724724
# XXX what about EINTR?
725-
if e.args[0] in _blocking_errnos:
725+
if e.errno in _blocking_errnos:
726726
return None
727727
raise
728728

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.