mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
[3.13] gh-135836: Fix IndexError
in asyncio.create_connection
with empty exceptions list (GH-135845) (#136168)
gh-135836: Fix `IndexError` in `asyncio.create_connection` with empty exceptions list (GH-135845)
(cherry picked from commit 0e19db653d
)
Co-authored-by: heliang666s <147408835+heliang666s@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
004f464338
commit
1994d2e5b1
3 changed files with 35 additions and 1 deletions
|
@ -1164,7 +1164,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
raise ExceptionGroup("create_connection failed", exceptions)
|
||||
if len(exceptions) == 1:
|
||||
raise exceptions[0]
|
||||
else:
|
||||
elif exceptions:
|
||||
# If they all have the same str(), raise one.
|
||||
model = str(exceptions[0])
|
||||
if all(str(exc) == model for exc in exceptions):
|
||||
|
@ -1173,6 +1173,9 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
# the various error messages.
|
||||
raise OSError('Multiple exceptions: {}'.format(
|
||||
', '.join(str(exc) for exc in exceptions)))
|
||||
else:
|
||||
# No exceptions were collected, raise a timeout error
|
||||
raise TimeoutError('create_connection failed')
|
||||
finally:
|
||||
exceptions = None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue