]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-148508: Add another common pattern for iOS SSL failures to test_ssl (#150442)
authorRussell Keith-Magee <russell@keith-magee.com>
Mon, 1 Jun 2026 09:37:53 +0000 (17:37 +0800)
committerGitHub <noreply@github.com>
Mon, 1 Jun 2026 09:37:53 +0000 (11:37 +0200)
Match also '[SSL: HTTP_REQUEST] http request (_ssl.c:1143)'.

Lib/test/test_ssl.py
Platforms/Apple/testbed/__main__.py

index a60e96053b86d19cafaf4df11bba37485b444626..4f998ef2b02a69a5d3e82129f200953090e740e1 100644 (file)
@@ -5698,17 +5698,24 @@ class TestPreHandshakeClose(unittest.TestCase):
             return  # Expect the full test setup to always work on Linux.
         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)
+            re.search(
+                # Matches the following error messages:
+                # '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)'
+                # '[SSL: RECORD_LAYER_FAILURE] record layer failure (_ssl.c:1109)'
+                # '[SSL: HTTP_REQUEST] http request (_ssl.c:1143)'
+                r'wrong.version.number|record.layer.failure|http.request',
+                str(getattr(err, "reason", "")),
+                re.IGNORECASE,
+            )
         ):
             # On Windows the TCP RST leads to a ConnectionResetError
             # (ECONNRESET) which Linux doesn't appear to surface to userspace.
             # If wrap_socket() winds up on the "if connected:" path and doing
             # the actual wrapping... we get an SSLError from OpenSSL. This is
             # typically WRONG_VERSION_NUMBER. The same happens on iOS, but
-            # RECORD_LAYER_FAILURE is the error.
+            # RECORD_LAYER_FAILURE or HTTP_REQUEST is the error.
             #
-            # While appropriate, neither is the scenario we're specifically
+            # While appropriate, these scenarios aren't what we're specifically
             # trying to test. The way this test is written is known to work on
             # Linux. We'll skip it anywhere else that it does not present as
             # doing so.
index 0dd77ab8b827974ea5b8ebd3c48ee47f9538c612..b3eed38571d9708b21f51e278612fafc88f0d685 100644 (file)
@@ -21,7 +21,7 @@ DECODE_ARGS = ("UTF-8", "backslashreplace")
 LOG_PREFIX_REGEX = re.compile(
     r"^\d{4}-\d{2}-\d{2}"  # YYYY-MM-DD
     r"\s+\d+:\d{2}:\d{2}\.\d+\+\d{4}"  # HH:MM:SS.ssssss+ZZZZ
-    r"\s+iOSTestbed\[\d+:\w+\]"  # Process/thread ID
+    r"\s+iOSTestbed\[\d+:\w+\] "  # Process/thread ID
 )