https://github.com/python/cpython/commit/a7ed0c9e1dee1397e80e2e0d90d110155da2bc30
commit: a7ed0c9e1dee1397e80e2e0d90d110155da2bc30
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-05-16T10:02:19Z
summary:
gh-149879: Fix test_socket on Cygwin (#149913)
Disable SCM_RIGHTS, recvmsg(), sendmsg() and sethostname() on Cygwin.
files:
M Lib/test/test_socket.py
M Modules/socketmodule.c
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 47830d0e9645ef..5b4c88793f8e23 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1454,7 +1454,7 @@ def testIPv6toString(self):
assertInvalid('1:2:3:4:5:6:')
assertInvalid('1:2:3:4:5:6:7:8:0')
# bpo-29972: inet_pton() doesn't fail on AIX
- if not AIX:
+ if not AIX and sys.platform != 'cygwin':
assertInvalid('1:2:3:4:5:6:7:8:')
self.assertEqual(b'\x00' * 12 + b'\xfe\x2a\x17\x40',
@@ -2001,7 +2001,8 @@ def test_getfqdn_filter_localhost(self):
self.assertEqual(socket.getfqdn(), socket.getfqdn("::"))
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 required for this
test.')
- @unittest.skipIf(sys.platform == 'win32', 'does not work on Windows')
+ @unittest.skipIf(sys.platform in ('win32', 'cygwin'),
+ 'does not work on Windows')
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
@unittest.skipUnless(hasattr(socket, 'if_nameindex'), "test needs
socket.if_nameindex()")
@support.skip_android_selinux('if_nameindex')
@@ -2035,7 +2036,7 @@ def test_getaddrinfo_ipv6_scopeid_numeric(self):
self.assertEqual(sockaddr, ('ff02::1de:c0:face:8d', 1234, 0, ifindex))
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 required for this
test.')
- @unittest.skipIf(sys.platform == 'win32', 'does not work on Windows')
+ @unittest.skipIf(sys.platform in ('win32', 'cygwin'), 'does not work on
Windows')
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
@unittest.skipUnless(hasattr(socket, 'if_nameindex'), "test needs
socket.if_nameindex()")
@support.skip_android_selinux('if_nameindex')
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index f5993fc8fdaab2..442834a556efc6 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -654,10 +654,6 @@ class _socket.socket "PySocketSockObject *"
"clinic_state()->sock_type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=2db2489bd2219fd8]*/
-#define clinic_state() (find_module_state_by_def(type))
-#include "clinic/socketmodule.c.h"
-#undef clinic_state
-
/* XXX There's a problem here: *static* functions are not supposed to have
a Py prefix (or use CapitalizedWords). Later... */
@@ -688,6 +684,18 @@ class _socket.socket "PySocketSockObject *"
"clinic_state()->sock_type"
#define IS_SELECTABLE(s) (_PyIsSelectable_fd((s)->sock_fd) ||
(s)->sock_timeout <= 0)
#endif
+// SCM_RIGHTS, sendmsg(), recvmsg() and sethostname() don't work properly on
+// Cygwin: disable these features.
+#ifdef __CYGWIN__
+# undef CMSG_LEN
+# undef SCM_RIGHTS
+# undef HAVE_SETHOSTNAME
+#endif
+
+#define clinic_state() (find_module_state_by_def(type))
+#include "clinic/socketmodule.c.h"
+#undef clinic_state
+
static PyObject*
select_error(void)
{
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]