Skip to content

Commit

Permalink
[3.12] gh-126499: test_ssl: Don't assume err.reason is a string (GH-1…
Browse files Browse the repository at this point in the history
…26501) (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 78ad7e6)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
  • Loading branch information
miss-islington and encukou authored Nov 11, 2024
1 parent 75d251b commit d62f100
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4817,7 +4817,7 @@ def non_linux_skip_if_other_okay_error(self, err):
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
Expand Down

0 comments on commit d62f100

Please sign in to comment.