gh-144493: Improve error message in _overlapped.BindLocal() (#144495)

Replace a confusing error message with one that actually explains what the error is in `_overlapped.BindLocal()`.

Fixes: https://github.com/python/cpython/issues/144493
This commit is contained in:
David Lechner 2026-02-06 02:51:19 -06:00 committed by GitHub
parent 957f9fe162
commit 56590f820e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View file

@ -0,0 +1 @@
Improve an exception error message in ``_overlapped.BindLocal()`` that is raised when :meth:`asyncio.loop.sock_connect` is called on a :class:`asyncio.ProactorEventLoop` with a socket that has an invalid address family.

View file

@ -559,7 +559,7 @@ _overlapped_BindLocal_impl(PyObject *module, HANDLE Socket, int Family)
ret = bind((SOCKET)Socket, (SOCKADDR*)&addr, sizeof(addr))
!= SOCKET_ERROR;
} else {
PyErr_SetString(PyExc_ValueError, "expected tuple of length 2 or 4");
PyErr_SetString(PyExc_ValueError, "Only AF_INET and AF_INET6 families are supported");
return NULL;
}