diff -rupN Python-2.7.13/configure.ac Python-2.7.13-new/configure.ac
--- Python-2.7.13/configure.ac 2017-01-21 01:46:07.135600840 +0100
+++ Python-2.7.13-new/configure.ac 2017-01-21 01:46:07.713594669 +0100
@@ -3740,21 +3740,36 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
],[])
AC_MSG_RESULT($was_it_defined)
+AC_CHECK_HEADERS([ws2tcpip.h])
AC_MSG_CHECKING(for addrinfo)
AC_CACHE_VAL(ac_cv_struct_addrinfo,
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#else
+# include <netdb.h>
+#endif]],
+ [[struct addrinfo a]])],
[ac_cv_struct_addrinfo=yes],
[ac_cv_struct_addrinfo=no]))
AC_MSG_RESULT($ac_cv_struct_addrinfo)
if test $ac_cv_struct_addrinfo = yes; then
- AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
+ AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo])
fi
AC_MSG_CHECKING(for sockaddr_storage)
AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-# include <sys/types.h>
-# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif]],
+ [[struct sockaddr_storage s]])],
[ac_cv_struct_sockaddr_storage=yes],
[ac_cv_struct_sockaddr_storage=no]))
AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
@@ -4913,7 +4928,10 @@ fi
AC_CHECK_TYPE(socklen_t,,
AC_DEFINE(socklen_t,int,
- [Define to `int' if <sys/socket.h> does not define.]),[
+ [Define to `int' if <sys/socket.h> or <ws2tcpip.h> does not define.]),[
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
diff -rupN Python-2.7.13/Misc/config_mingw Python-2.7.13-new/Misc/config_mingw
--- Python-2.7.13/Misc/config_mingw 2017-01-21 01:46:04.950624168 +0100
+++ Python-2.7.13-new/Misc/config_mingw 2017-01-21 01:46:07.713594669 +0100
@@ -10,3 +10,6 @@ ac_cv_func_alarm=ignore
# files to ignore
ac_cv_file__dev_ptmx=ignore #NOTE: under MSYS environment device exist
ac_cv_file__dev_ptc=no
+
+# force detection of winsock2 functionality - require wxp or newer
+ac_cv_func_getpeername=yes
diff -rupN Python-2.7.13/Modules/socketmodule.c Python-2.7.13-new/Modules/socketmodule.c
--- Python-2.7.13/Modules/socketmodule.c 2016-12-17 21:05:07.000000000 +0100
+++ Python-2.7.13-new/Modules/socketmodule.c 2017-01-21 01:46:07.714594658 +0100
@@ -341,6 +341,12 @@ int h_errno; /* not used */
/* Do not include addrinfo.h for MSVC7 or greater. 'addrinfo' and
* EAI_* constants are defined in (the already included) ws2tcpip.h.
*/
+#elif defined(__MINGW32__)
+ /* Do not include addrinfo.h as minimum supported version is
+ * _WIN32_WINNT >= WindowsXP(0x0501)
+ */
+# define HAVE_GETADDRINFO
+# define HAVE_GETNAMEINFO
#else
# include "addrinfo.h"
#endif
diff -rupN Python-2.7.13/pyconfig.h.in Python-2.7.13-new/pyconfig.h.in
--- Python-2.7.13/pyconfig.h.in 2017-01-21 01:46:05.563617623 +0100
+++ Python-2.7.13-new/pyconfig.h.in 2017-01-21 01:46:07.714594658 +0100
@@ -49,7 +49,7 @@
/* Define to 1 if you have the `acosh' function. */
#undef HAVE_ACOSH
-/* struct addrinfo (netdb.h) */
+/* struct addrinfo */
#undef HAVE_ADDRINFO
/* Define to 1 if you have the `alarm' function. */
@@ -921,6 +921,9 @@
*/
#undef HAVE_WORKING_TZSET
+/* Define to 1 if you have the <ws2tcpip.h> header file. */
+#undef HAVE_WS2TCPIP_H
+
/* Define if the zlib library has inflateCopy */
#undef HAVE_ZLIB_COPY
@@ -1262,7 +1265,7 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
-/* Define to `int' if <sys/socket.h> does not define. */
+/* Define to `int' if <sys/socket.h> or <ws2tcpip.h> does not define. */
#undef socklen_t
/* Define to `int' if <sys/types.h> doesn't define. */
diff -rupN Python-2.7.13/setup.py Python-2.7.13-new/setup.py
--- Python-2.7.13/setup.py 2017-01-21 01:46:07.711594690 +0100
+++ Python-2.7.13-new/setup.py 2017-01-21 01:46:07.715594647 +0100
@@ -811,9 +811,12 @@ class PyBuildExt(build_ext):
exts.append( Extension('_csv', ['_csv.c']) )
# socket(2)
+ _socket_libs = math_libs
+ if host_platform == 'win32':
+ _socket_libs.append('ws2_32')
exts.append( Extension('_socket', ['socketmodule.c', 'timemodule.c'],
depends=['socketmodule.h'],
- libraries=math_libs) )
+ libraries=_socket_libs) )
# Detect SSL support for the socket module (via _ssl)
search_for_ssl_incs_in = [
'/usr/local/ssl/include',