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
Prev Previous commit
Next Next commit
bpo-23451: Add SUPPRESS_DEPRECATED_CALL to socketmodule.c
  • Loading branch information
segevfiner committed Jun 24, 2017
commit ad12653dac3d3a927024a06af865ec08dc03589e
6 changes: 6 additions & 0 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,13 @@ select_error(void)
# define SET_SOCK_ERROR(err) WSASetLastError(err)
# define SOCK_TIMEOUT_ERR WSAEWOULDBLOCK
# define SOCK_INPROGRESS_ERR WSAEWOULDBLOCK
# define SUPPRESS_DEPRECATED_CALL __pragma(warning(suppress: 4996))
#else
# define GET_SOCK_ERROR errno
# define SET_SOCK_ERROR(err) do { errno = err; } while (0)
# define SOCK_TIMEOUT_ERR EWOULDBLOCK
# define SOCK_INPROGRESS_ERR EINPROGRESS
# define SUPPRESS_DEPRECATED_CALL
#endif


Expand Down Expand Up @@ -5109,6 +5111,7 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
#ifdef USE_GETHOSTBYNAME_LOCK
PyThread_acquire_lock(netdb_lock, 1);
#endif
SUPPRESS_DEPRECATED_CALL
h = gethostbyname(name);
#endif /* HAVE_GETHOSTBYNAME_R */
Py_END_ALLOW_THREADS
Expand Down Expand Up @@ -5207,6 +5210,7 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
#ifdef USE_GETHOSTBYNAME_LOCK
PyThread_acquire_lock(netdb_lock, 1);
#endif
SUPPRESS_DEPRECATED_CALL
h = gethostbyaddr(ap, al, af);
#endif /* HAVE_GETHOSTBYNAME_R */
Py_END_ALLOW_THREADS
Expand Down Expand Up @@ -5659,6 +5663,7 @@ socket_inet_aton(PyObject *self, PyObject *args)
packed_addr = INADDR_BROADCAST;
} else {

SUPPRESS_DEPRECATED_CALL
packed_addr = inet_addr(ip_addr);

if (packed_addr == INADDR_NONE) { /* invalid address */
Expand Down Expand Up @@ -5702,6 +5707,7 @@ socket_inet_ntoa(PyObject *self, PyObject *args)
memcpy(&packed_addr, packed_ip.buf, packed_ip.len);
PyBuffer_Release(&packed_ip);

SUPPRESS_DEPRECATED_CALL
return PyUnicode_FromString(inet_ntoa(packed_addr));
}

Expand Down