bpo-39148: enable ipv6 for datagrams in Proactor (GH-19121)
Ifdef is not necessary, as AF_INET6 is supported from Windows Vista, and other code in overlapped.c uses AF_INET6 and is not ifdef'd.
Change the raised exception so users are not fooled to think it comes from Windows API.
Automerge-Triggered-By: @njsmith
(cherry picked from commit 442634c42fcaf31c636f693951a97734042c3e7b)
Co-authored-by: Kjell Braden <afflux@pentabarf.de>
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index 52ed0bc..b35f708 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -670,7 +670,6 @@
return PyUnicode_FromString(buf);
}
-#ifdef ENABLE_IPV6
/* Convert IPv6 sockaddr to a Python str. */
static PyObject *
@@ -683,7 +682,6 @@
}
return PyUnicode_FromString(buf);
}
-#endif
static PyObject*
unparse_address(LPSOCKADDR Address, DWORD Length)
@@ -701,7 +699,6 @@
}
return ret;
}
-#ifdef ENABLE_IPV6
case AF_INET6: {
const struct sockaddr_in6 *a = (const struct sockaddr_in6 *)Address;
PyObject *addrobj = make_ipv6_addr(a);
@@ -716,9 +713,9 @@
}
return ret;
}
-#endif /* ENABLE_IPV6 */
default: {
- return SetFromWindowsErr(ERROR_INVALID_PARAMETER);
+ PyErr_SetString(PyExc_ValueError, "recvfrom returned unsupported address family");
+ return NULL;
}
}
}