Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-23451: Fix socket deprecation warnings in socketmodule.c #2318

Merged
merged 10 commits into from
Jun 28, 2017
Next Next commit
bpo-23451: Fix WSASocket and WSADuplicateSocket deprecation warnings
  • Loading branch information
segevfiner committed Jun 21, 2017
commit 4201fbf48f1f1003c928a3d6ddf0ebca59f84989
16 changes: 8 additions & 8 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4397,15 +4397,15 @@ SIO_LOOPBACK_FAST_PATH: 'option' is a boolean value, and is disabled by default"
static PyObject*
sock_share(PySocketSockObject *s, PyObject *arg)
{
WSAPROTOCOL_INFO info;
WSAPROTOCOL_INFOW info;
DWORD processId;
int result;

if (!PyArg_ParseTuple(arg, "I", &processId))
return NULL;

Py_BEGIN_ALLOW_THREADS
result = WSADuplicateSocket(s->sock_fd, processId, &info);
result = WSADuplicateSocketW(s->sock_fd, processId, &info);
Py_END_ALLOW_THREADS
if (result == SOCKET_ERROR)
return set_error();
Expand Down Expand Up @@ -4636,7 +4636,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
#ifdef MS_WINDOWS
/* recreate a socket that was duplicated */
if (PyBytes_Check(fdobj)) {
WSAPROTOCOL_INFO info;
WSAPROTOCOL_INFOW info;
if (PyBytes_GET_SIZE(fdobj) != sizeof(info)) {
PyErr_Format(PyExc_ValueError,
"socket descriptor string has wrong size, "
Expand All @@ -4645,7 +4645,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
}
memcpy(&info, PyBytes_AS_STRING(fdobj), sizeof(info));
Py_BEGIN_ALLOW_THREADS
fd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
fd = WSASocketW(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
FROM_PROTOCOL_INFO, &info, 0, WSA_FLAG_OVERLAPPED);
Py_END_ALLOW_THREADS
if (fd == INVALID_SOCKET) {
Expand Down Expand Up @@ -4678,7 +4678,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)

Py_BEGIN_ALLOW_THREADS
if (support_wsa_no_inherit) {
fd = WSASocket(family, type, proto,
fd = WSASocketW(family, type, proto,
NULL, 0,
WSA_FLAG_OVERLAPPED | WSA_FLAG_NO_HANDLE_INHERIT);
if (fd == INVALID_SOCKET) {
Expand Down Expand Up @@ -5336,18 +5336,18 @@ socket_dup(PyObject *self, PyObject *fdobj)
SOCKET_T fd, newfd;
PyObject *newfdobj;
#ifdef MS_WINDOWS
WSAPROTOCOL_INFO info;
WSAPROTOCOL_INFOW info;
#endif

fd = PyLong_AsSocket_t(fdobj);
if (fd == (SOCKET_T)(-1) && PyErr_Occurred())
return NULL;

#ifdef MS_WINDOWS
if (WSADuplicateSocket(fd, GetCurrentProcessId(), &info))
if (WSADuplicateSocketW(fd, GetCurrentProcessId(), &info))
return set_error();

newfd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
newfd = WSASocketW(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
FROM_PROTOCOL_INFO,
&info, 0, WSA_FLAG_OVERLAPPED);
if (newfd == INVALID_SOCKET)
Expand Down