From: Yury Selivanov Date: Mon, 16 May 2016 19:20:38 +0000 (-0400) Subject: Issue #27040: Add loop.get_exception_handler method X-Git-Tag: v3.5.2rc1~158 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ed7ce6ee76c1e4aaa94151f156fb2ba5163b5b2;p=thirdparty%2FPython%2Fcpython.git Issue #27040: Add loop.get_exception_handler method --- diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 3703480eba0e..ada178f37f4b 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1078,6 +1078,11 @@ class BaseEventLoop(events.AbstractEventLoop): logger.info('%s: %r' % (debug_log, transport)) return transport, protocol + def get_exception_handler(self): + """Return an exception handler, or None if the default one is in use. + """ + return self._exception_handler + def set_exception_handler(self, handler): """Set handler as the new event loop exception handler. diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py index 176a84669844..8358ebfd4f15 100644 --- a/Lib/asyncio/events.py +++ b/Lib/asyncio/events.py @@ -484,6 +484,9 @@ class AbstractEventLoop: # Error handlers. + def get_exception_handler(self): + raise NotImplementedError + def set_exception_handler(self, handler): raise NotImplementedError diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index a74ac8963a2a..ef93dc0e0333 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -658,8 +658,10 @@ class BaseEventLoopTests(test_utils.TestCase): self.loop.set_debug(True) self.loop._process_events = mock.Mock() + self.assertIsNone(self.loop.get_exception_handler()) mock_handler = mock.Mock() self.loop.set_exception_handler(mock_handler) + self.assertIs(self.loop.get_exception_handler(), mock_handler) handle = run_loop() mock_handler.assert_called_with(self.loop, { 'exception': MOCK_ANY, diff --git a/Misc/NEWS b/Misc/NEWS index 6697db5f1458..abffd52c0dd4 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -454,6 +454,8 @@ Library - Issue #26848: Fix asyncio/subprocess.communicate() to handle empty input. Patch by Jack O'Connor. +- Issue #27040: Add loop.get_exception_handler method + Documentation -------------