Skip to content

Commit

Permalink
gh-126499: test_ssl: Don't assume err.reason is a string (GH-126501)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
encukou authored Nov 7, 2024
1 parent 1fe67df commit 78ad7e6
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 @@ -5029,7 +5029,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 78ad7e6

Please sign in to comment.