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

Skip to content
Closed
Prev Previous commit
Map ESHUTDOWN to EPIPE
  • Loading branch information
tiran committed Jul 23, 2022
commit a2f80e52aa8826352aa255f2b16075ebda7a6dd9
15 changes: 3 additions & 12 deletions Lib/asyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
sophisticated high-performance network servers and clients a snap.
"""

from builtins import frozenset
import select
import socket
import sys
Expand All @@ -55,23 +54,15 @@

import os
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
ENOTCONN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
errorcode

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

_DISCONNECTED = {ECONNRESET, ENOTCONN, ECONNABORTED, EPIPE, EBADF}

try:
from errno import ESHUTDOWN
except ImportError:
pass
else:
_DISCONNECTED.add(ESHUTDOWN)

_DISCONNECTED = frozenset(_DISCONNECTED)
_DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
EBADF})

try:
socket_map
Expand Down
5 changes: 1 addition & 4 deletions Lib/test/test_exception_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ def _make_map(s):
continue
excname, _, errnames = line.partition(' ')
for errname in filter(None, errnames.strip().split(', ')):
errval = getattr(errno, errname, None)
if errval is None:
continue
_map[errval] = getattr(builtins, excname)
_map[getattr(errno, errname)] = getattr(builtins, excname)
return _map
_map = _make_map(_pep_map)

Expand Down
4 changes: 4 additions & 0 deletions Modules/errnomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ errno_exec(PyObject *module)
#ifdef ENOANO
add_errcode("ENOANO", ENOANO, "No anode");
#endif
#if defined(__wasi__) && !defined(ESHUTDOWN)
// WASI SDK 16 does not have ESHUTDOWN, shutdown results in EPIPE.
#define ESHUTDOWN EPIPE
#endif
#ifdef ESHUTDOWN
add_errcode("ESHUTDOWN", ESHUTDOWN, "Cannot send after transport endpoint shutdown");
#else
Expand Down