Skip to content

Commit 4e4c386

Browse files
committed
Do not log exceptions (they are propagated anyways)
1 parent 24e5520 commit 4e4c386

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

Lib/asyncio/sslproto.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -709,16 +709,9 @@ def _fatal_error(self, exc, message='Fatal error on transport'):
709709
if self._transport:
710710
self._transport._force_close(exc)
711711

712-
if isinstance(exc, base_events._FATAL_ERROR_IGNORE):
713-
if self._loop.get_debug():
714-
logger.debug("%r: %s", self, message, exc_info=True)
715-
elif not isinstance(exc, futures.CancelledError):
716-
self._loop.call_exception_handler({
717-
'message': message,
718-
'exception': exc,
719-
'transport': self._transport,
720-
'protocol': self,
721-
})
712+
if (self._loop.get_debug() and
713+
isinstance(exc, base_events._FATAL_ERROR_IGNORE)):
714+
logger.debug("%r: %s", self, message, exc_info=True)
722715

723716
def _finalize(self):
724717
self._sslpipe = None

Lib/test/test_asyncio/test_sslproto.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ def test_handshake_timeout(self):
514514
# completed in timeout period, instead of remaining open indefinitely
515515
client_sslctx = test_utils.simple_client_sslcontext()
516516

517-
# silence error logger
518517
messages = []
519518
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
520519

@@ -556,8 +555,8 @@ async def client(addr):
556555
def test_create_connection_ssl_slow_handshake(self):
557556
client_sslctx = test_utils.simple_client_sslcontext()
558557

559-
# silence error logger
560-
self.loop.set_exception_handler(lambda *args: None)
558+
messages = []
559+
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
561560

562561
def server(sock):
563562
try:
@@ -585,9 +584,11 @@ async def client(addr):
585584

586585
self.loop.run_until_complete(client(srv.addr))
587586

587+
self.assertEqual(messages, [])
588+
588589
def test_create_connection_ssl_failed_certificate(self):
589-
# silence error logger
590-
self.loop.set_exception_handler(lambda *args: None)
590+
messages = []
591+
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
591592

592593
sslctx = test_utils.simple_server_sslcontext()
593594
client_sslctx = test_utils.simple_client_sslcontext(
@@ -619,6 +620,8 @@ async def client(addr):
619620
with self.assertRaises(ssl.SSLCertVerificationError):
620621
self.loop.run_until_complete(client(srv.addr))
621622

623+
self.assertEqual(messages, [])
624+
622625

623626
@unittest.skipIf(ssl is None, 'No ssl module')
624627
class SelectorStartTLSTests(BaseStartTLS, unittest.TestCase):

0 commit comments

Comments
 (0)