gh-121913: Use str(exc) instead of exc.strerror in asyncio.base_events (#122269)

This commit is contained in:
AN Long 2024-07-25 19:56:04 +08:00 committed by GitHub
parent 6c09b8de5c
commit 070f1e2e5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1028,8 +1028,7 @@ class BaseEventLoop(events.AbstractEventLoop):
except OSError as exc: except OSError as exc:
msg = ( msg = (
f'error while attempting to bind on ' f'error while attempting to bind on '
f'address {laddr!r}: ' f'address {laddr!r}: {str(exc).lower()}'
f'{exc.strerror.lower()}'
) )
exc = OSError(exc.errno, msg) exc = OSError(exc.errno, msg)
my_exceptions.append(exc) my_exceptions.append(exc)
@ -1599,7 +1598,7 @@ class BaseEventLoop(events.AbstractEventLoop):
except OSError as err: except OSError as err:
msg = ('error while attempting ' msg = ('error while attempting '
'to bind on address %r: %s' 'to bind on address %r: %s'
% (sa, err.strerror.lower())) % (sa, str(err).lower()))
if err.errno == errno.EADDRNOTAVAIL: if err.errno == errno.EADDRNOTAVAIL:
# Assume the family is not enabled (bpo-30945) # Assume the family is not enabled (bpo-30945)
sockets.pop() sockets.pop()