]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149879: Fix test_ssl on Cygwin (#150419)
authorVictor Stinner <vstinner@python.org>
Mon, 25 May 2026 20:32:37 +0000 (22:32 +0200)
committerGitHub <noreply@github.com>
Mon, 25 May 2026 20:32:37 +0000 (22:32 +0200)
On Cygwin, ignore EAGAIN in SSLSocket._create() if getpeername() fails.

Lib/ssl.py
Lib/test/test_ssl.py

index 896db17baeb3dbde6eb9a824262250389e2ef101..f23bcbe75e7201fb8ee7e29b15b2ef9ac20ad6e5 100644 (file)
@@ -1055,7 +1055,12 @@ class SSLSocket(socket):
                     notconn_pre_handshake_data = self.recv(1)
                 except OSError as e:
                     # EINVAL occurs for recv(1) on non-connected on unix sockets.
-                    if e.errno not in (errno.ENOTCONN, errno.EINVAL):
+                    if e.errno in (errno.ENOTCONN, errno.EINVAL):
+                        pass
+                    elif sys.platform == 'cygwin' and e.errno == errno.EAGAIN:
+                        # EAGAIN occurs on Cygwin.
+                        pass
+                    else:
                         raise
                     notconn_pre_handshake_data = b''
                 self.setblocking(blocking)
index 7f23727661715290e6b19b0c0345cd06f77a7894..a60e96053b86d19cafaf4df11bba37485b444626 100644 (file)
@@ -638,6 +638,7 @@ class BasicSocketTests(unittest.TestCase):
             del ss
         self.assertEqual(wr(), None)
 
+    @unittest.skipIf(sys.platform == 'cygwin', 'test hangs on Cygwin')
     def test_wrapped_unconnected(self):
         # Methods on an unconnected SSLSocket propagate the original
         # OSError raise by the underlying socket object.
@@ -3631,7 +3632,7 @@ class ThreadedTests(unittest.TestCase):
                 OSError,
                 'alert unknown ca|EOF occurred|TLSV1_ALERT_UNKNOWN_CA|'
                 'closed by the remote host|Connection reset by peer|'
-                'Broken pipe'
+                'Broken pipe|Software caused connection abort'
             ):
                 # TLS 1.3 perform client cert exchange after handshake
                 s.write(b'data')
@@ -4585,6 +4586,8 @@ class ThreadedTests(unittest.TestCase):
             ssl.SSLError,
             # On handshake failures, some systems raise a ConnectionResetError.
             ConnectionResetError,
+            # On handshake failures, Cygwin raises ConnectionAbortedError.
+            ConnectionAbortedError,
             # On handshake failures, macOS may raise a BrokenPipeError.
             # See https://github.com/python/cpython/issues/139504.
             BrokenPipeError,
@@ -5693,7 +5696,7 @@ class TestPreHandshakeClose(unittest.TestCase):
     def non_linux_skip_if_other_okay_error(self, err):
         if sys.platform in ("linux", "android"):
             return  # Expect the full test setup to always work on Linux.
-        if (isinstance(err, ConnectionResetError) or
+        if (isinstance(err, (ConnectionResetError, ConnectionAbortedError)) or
             (isinstance(err, OSError) and err.errno == errno.EINVAL) or
             re.search('wrong.version.number', str(getattr(err, "reason", "")), re.I) or
             re.search('record.layer.failure', str(getattr(err, "reason", "")), re.I)