]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-126499: test_ssl: Don't assume err.reason is a string (GH-126501)
authorPetr Viktorin <encukou@gmail.com>
Thu, 7 Nov 2024 10:06:27 +0000 (11:06 +0100)
committerGitHub <noreply@github.com>
Thu, 7 Nov 2024 10:06:27 +0000 (11:06 +0100)
The skipping machinery called `getattr(err, "reason", "")` on an arbitrary
exception. As intermittent Buildbot failures show, sometimes it's set
to None.

Convert it to string for this specific check.

Lib/test/test_ssl.py

index de5110a1cc4b6d8cdf4535f636f35617c5639f59..ca9dac97c8e2131d6c24b113ddf60b8a2b839109 100644 (file)
@@ -5029,7 +5029,7 @@ class TestPreHandshakeClose(unittest.TestCase):
             return  # Expect the full test setup to always work on Linux.
         if (isinstance(err, ConnectionResetError) or
             (isinstance(err, OSError) and err.errno == errno.EINVAL) or
-            re.search('wrong.version.number', getattr(err, "reason", ""), re.I)):
+            re.search('wrong.version.number', str(getattr(err, "reason", "")), re.I)):
             # 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