Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2f80e5

Browse files
committed
Map ESHUTDOWN to EPIPE
1 parent b50b83b commit a2f80e5

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

Lib/asyncore.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
sophisticated high-performance network servers and clients a snap.
4747
"""
4848

49-
from builtins import frozenset
5049
import select
5150
import socket
5251
import sys
@@ -55,23 +54,15 @@
5554

5655
import os
5756
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
58-
ENOTCONN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
57+
ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
5958
errorcode
6059

6160
_DEPRECATION_MSG = ('The {name} module is deprecated and will be removed in '
6261
'Python {remove}. The recommended replacement is asyncio')
6362
warnings._deprecated(__name__, _DEPRECATION_MSG, remove=(3, 12))
6463

65-
_DISCONNECTED = {ECONNRESET, ENOTCONN, ECONNABORTED, EPIPE, EBADF}
66-
67-
try:
68-
from errno import ESHUTDOWN
69-
except ImportError:
70-
pass
71-
else:
72-
_DISCONNECTED.add(ESHUTDOWN)
73-
74-
_DISCONNECTED = frozenset(_DISCONNECTED)
64+
_DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
65+
EBADF})
7566

7667
try:
7768
socket_map

Lib/test/test_exception_hierarchy.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ def _make_map(s):
7575
continue
7676
excname, _, errnames = line.partition(' ')
7777
for errname in filter(None, errnames.strip().split(', ')):
78-
errval = getattr(errno, errname, None)
79-
if errval is None:
80-
continue
81-
_map[errval] = getattr(builtins, excname)
78+
_map[getattr(errno, errname)] = getattr(builtins, excname)
8279
return _map
8380
_map = _make_map(_pep_map)
8481

Modules/errnomodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@ errno_exec(PyObject *module)
280280
#ifdef ENOANO
281281
add_errcode("ENOANO", ENOANO, "No anode");
282282
#endif
283+
#if defined(__wasi__) && !defined(ESHUTDOWN)
284+
// WASI SDK 16 does not have ESHUTDOWN, shutdown results in EPIPE.
285+
#define ESHUTDOWN EPIPE
286+
#endif
283287
#ifdef ESHUTDOWN
284288
add_errcode("ESHUTDOWN", ESHUTDOWN, "Cannot send after transport endpoint shutdown");
285289
#else

0 commit comments

Comments
 (0)