From 602d7ed43f40bf769d7bad3235d5e36a89899359 Mon Sep 17 00:00:00 2001 From: AN Long Date: Thu, 25 Jul 2024 19:56:04 +0800 Subject: [PATCH] gh-121913: Use str(exc) instead of exc.strerror in `asyncio.base_events` (GH-122269) (cherry picked from commit 070f1e2e5b9b31ee3e7a1af2e30d7e3a66040b17) Co-authored-by: AN Long --- Lib/asyncio/base_events.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 29eff0499cb1d6..cb037fd472c5aa 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -994,8 +994,7 @@ async def _connect_sock(self, exceptions, addr_info, local_addr_infos=None): except OSError as exc: msg = ( f'error while attempting to bind on ' - f'address {laddr!r}: ' - f'{exc.strerror.lower()}' + f'address {laddr!r}: {str(exc).lower()}' ) exc = OSError(exc.errno, msg) my_exceptions.append(exc) @@ -1561,7 +1560,7 @@ async def create_server( except OSError as err: msg = ('error while attempting ' 'to bind on address %r: %s' - % (sa, err.strerror.lower())) + % (sa, str(err).lower())) if err.errno == errno.EADDRNOTAVAIL: # Assume the family is not enabled (bpo-30945) sockets.pop()