]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-144493: Improve error message in _overlapped.BindLocal() (#144495)
authorDavid Lechner <david@lechnology.com>
Fri, 6 Feb 2026 08:51:19 +0000 (02:51 -0600)
committerGitHub <noreply@github.com>
Fri, 6 Feb 2026 08:51:19 +0000 (09:51 +0100)
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
Misc/NEWS.d/next/Library/2026-02-05-17-15-31.gh-issue-144493.XuxwVu.rst [new file with mode: 0644]
Modules/overlapped.c

diff --git a/Misc/NEWS.d/next/Library/2026-02-05-17-15-31.gh-issue-144493.XuxwVu.rst b/Misc/NEWS.d/next/Library/2026-02-05-17-15-31.gh-issue-144493.XuxwVu.rst
new file mode 100644 (file)
index 0000000..fe205b5
--- /dev/null
@@ -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.
index 09b57ce4b9773abe8d0e9e0a47ff6ffd61effbc5..8c3575ff5678ebecab853e996e9a4616efa54ade 100644 (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;
     }