[Python-checkins] cpython (merge 3.5 -> default): Merge 3.5 (issue #27040)

yury.selivanov python-checkins at python.org
Mon May 16 15:32:32 EDT 2016


https://hg.python.org/cpython/rev/a3db6aee74f3
changeset:   101381:a3db6aee74f3
parent:      101379:3eb502d43616
parent:      101380:f51ecf47d416
user:        Yury Selivanov <yselivanov at sprymix.com>
date:        Mon May 16 15:32:26 2016 -0400
summary:
  Merge 3.5 (issue #27040)

files:
  Lib/asyncio/base_events.py                |  5 +++++
  Lib/asyncio/events.py                     |  3 +++
  Lib/test/test_asyncio/test_base_events.py |  2 ++
  Misc/NEWS                                 |  2 ++
  4 files changed, 12 insertions(+), 0 deletions(-)


diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1079,6 +1079,11 @@
             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
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -484,6 +484,9 @@
 
     # 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
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -658,8 +658,10 @@
         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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -979,6 +979,8 @@
 - Issue #26848: Fix asyncio/subprocess.communicate() to handle empty input.
   Patch by Jack O'Connor.
 
+- Issue #27040: Add loop.get_exception_handler method
+
 IDLE
 ----
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list