Skip to content

Commit

Permalink
Fix misleading message in the string representation of `ClientConnect…
Browse files Browse the repository at this point in the history
…orError` (#4097) (#4120)
  • Loading branch information
Transfusion authored and asvetlov committed Oct 1, 2019
1 parent 969188d commit ac180b1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/4097.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix misleading message in the string representation of `ClientConnectorError`; `self.ssl == None` means certification checks relaxed, not SSL disabled
5 changes: 3 additions & 2 deletions aiohttp/client_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ def ssl(self) -> Union[SSLContext, None, bool, 'Fingerprint']:
return self._conn_key.ssl

def __str__(self) -> str:
return ('Cannot connect to host {0.host}:{0.port} ssl:{0.ssl} [{1}]'
.format(self, self.strerror))
return ('Cannot connect to host {0.host}:{0.port} ssl:{1} [{2}]'
.format(self, self.ssl if self.ssl is not None else 'default',
self.strerror))

# OSError.__reduce__ does too much black magick
__reduce__ = BaseException.__reduce__
Expand Down
4 changes: 2 additions & 2 deletions tests/test_client_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def test_str(self) -> None:
err = client.ClientConnectorError(
connection_key=self.connection_key,
os_error=OSError(errno.ENOENT, 'No such file'))
assert str(err) == ("Cannot connect to host example.com:8080 ssl:None "
"[No such file]")
assert str(err) == ("Cannot connect to host example.com:8080 ssl:"
"default [No such file]")


class TestClientConnectorCertificateError:
Expand Down

0 comments on commit ac180b1

Please sign in to comment.