Skip to content

test_ssl: non_linux_skip_if_other_okay_error assumes err.reason is a string #126499

Closed
@encukou

Description

@encukou

Recently, test_ssl has been failing intermittently but frequently on macOS buildbots, see for example here.

Since #108315, there's some code to skip tests, which does getattr(err, "reason", "") on an arbitrary exception and expects that to be a string. If reason is set to None, a regex search on it fails. This prevents the calling test from checking that the error is correct.

Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_ssl.py", line 5085, in test_preauth_data_to_tls_server
    self.non_linux_skip_if_other_okay_error(wrap_error)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_ssl.py", line 5032, in non_linux_skip_if_other_okay_error
    re.search('wrong.version.number', getattr(err, "reason", ""), re.I)):
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/re/__init__.py", line 177, in search
    return _compile(pattern, flags).search(string)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

I'll send a PR soon.

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions