https://github.com/python/cpython/commit/56590f820e94987edf532f7b47772452a25d9c8f
commit: 56590f820e94987edf532f7b47772452a25d9c8f
branch: main
author: David Lechner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-02-06T09:51:19+01:00
summary:

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

files:
A Misc/NEWS.d/next/Library/2026-02-05-17-15-31.gh-issue-144493.XuxwVu.rst
M 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
index 00000000000000..fe205b58013af0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-02-05-17-15-31.gh-issue-144493.XuxwVu.rst
@@ -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.
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index 09b57ce4b9773a..8c3575ff5678eb 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -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;
     }
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to