From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:56:08 +0000 (+0100) Subject: [3.12] gh-126499: test_ssl: Don't assume err.reason is a string (GH-126501) (GH-126573) X-Git-Tag: v3.12.8~85 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d62f100fe1184c3d14d1ee51cfaaf3542c236ae7;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-126499: test_ssl: Don't assume err.reason is a string (GH-126501) (GH-126573) gh-126499: test_ssl: Don't assume err.reason is a string (GH-126501) 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. (cherry picked from commit 78ad7e632248dc989378cabeb797b9f3d940d9f2) Co-authored-by: Petr Viktorin --- diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 9b59ddd887aa..177523426622 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -4817,7 +4817,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