8000 gh-135836: Fix IndexError in asyncio.create_connection with empty exceptions list by heliang666s · Pull Request #135845 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-135836: Fix IndexError in asyncio.create_connection with empty exceptions list #135845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ async def create_connection(
raise ExceptionGroup("create_connection failed", exceptions)
if len(exceptions) == 1:
raise exceptions[0]
else:
elif len(exceptions) > 1:
# If they all have the 8000 same str(), raise one.
model = str(exceptions[0])
if all(str(exc) == model for exc in exceptions):
Expand All @@ -1170,6 +1170,9 @@ async def create_connection(
# the various error messages.
raise OSError('Multiple exceptions: {}'.format(
', '.join(str(exc) for exc in exceptions)))
else:
# No exceptions were collected, raise a generic connection error
raise OSError('create_connection failed')
finally:
exceptions = None

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed :exc:`IndexError` in ``asyncio.create_connection()`` that could occur when the Happy Eyeballs algorithm resulted in an empty exceptions list during connection attempts.
Loading
0