Skip to content

Commit

Permalink
pythongh-126499: test_ssl: Don't assume err.reason is a string (pytho…
Browse files Browse the repository at this point in the history
…nGH-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
encukou authored and miss-islington committed Nov 8, 2024
1 parent a0866f4 commit 29fa445
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 29fa445

Please sign in to comment.