-
-
Notifications
You must be signed in to change notification settings - Fork 34k
Open
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
When calling loop.sock_connect() on Windows, it calls into _overlapped_BindLocal_impl().
Lines 539 to 569 in b6d8aa4
| static PyObject * | |
| _overlapped_BindLocal_impl(PyObject *module, HANDLE Socket, int Family) | |
| /*[clinic end generated code: output=edb93862697aed9c input=a0e7b5c2f541170c]*/ | |
| { | |
| BOOL ret; | |
| if (Family == AF_INET) { | |
| struct sockaddr_in addr; | |
| memset(&addr, 0, sizeof(addr)); | |
| addr.sin_family = AF_INET; | |
| addr.sin_port = 0; | |
| addr.sin_addr.S_un.S_addr = INADDR_ANY; | |
| ret = bind((SOCKET)Socket, (SOCKADDR*)&addr, sizeof(addr)) | |
| != SOCKET_ERROR; | |
| } else if (Family == AF_INET6) { | |
| struct sockaddr_in6 addr; | |
| memset(&addr, 0, sizeof(addr)); | |
| addr.sin6_family = AF_INET6; | |
| addr.sin6_port = 0; | |
| addr.sin6_addr = in6addr_any; | |
| ret = bind((SOCKET)Socket, (SOCKADDR*)&addr, sizeof(addr)) | |
| != SOCKET_ERROR; | |
| } else { | |
| PyErr_SetString(PyExc_ValueError, "expected tuple of length 2 or 4"); | |
| return NULL; | |
| } | |
| if (!ret) | |
| return SetFromWindowsErr(WSAGetLastError()); | |
| Py_RETURN_NONE; | |
| } |
If the socket is not an AF_INET or AF_INET6 socket (for example an AF_BLUETOOTH socket), a ValueError is raised with the message: "expected tuple of length 2 or 4". This makes no sense. The actual problem is that the function only supports the two IP families. The error message should explain this.
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error