]> granicus.if.org Git - python/commitdiff
Does not install a logging handler. Fixes issue 10626.
authorBrian Quinlan <brian@sweetapp.com>
Tue, 28 Dec 2010 21:14:34 +0000 (21:14 +0000)
committerBrian Quinlan <brian@sweetapp.com>
Tue, 28 Dec 2010 21:14:34 +0000 (21:14 +0000)
Lib/concurrent/futures/_base.py
Lib/test/test_concurrent_futures.py

index 0bbb85bd462033a42599329ab03d549460f3c967..79b91d495fca987366c9b64a952e361a4e49a0d5 100644 (file)
@@ -41,8 +41,6 @@ _STATE_TO_DESCRIPTION_MAP = {
 
 # Logger for internal use by the futures package.
 LOGGER = logging.getLogger("concurrent.futures")
-STDERR_HANDLER = logging.StreamHandler()
-LOGGER.addHandler(STDERR_HANDLER)
 
 class Error(Exception):
     """Base class for all future-related exceptions."""
index 876d99407156dc0031f5a3c045512f514f788f00..6a95a362d444e16cbc34c15edf1c72ca0f3d4900 100644 (file)
@@ -24,7 +24,7 @@ if sys.platform.startswith('win'):
 from concurrent import futures
 from concurrent.futures._base import (
     PENDING, RUNNING, CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED, Future,
-    LOGGER, STDERR_HANDLER, wait)
+    LOGGER, wait)
 import concurrent.futures.process
 
 def create_future(state=PENDING, exception=None, result=None):
@@ -632,11 +632,7 @@ class FutureTests(unittest.TestCase):
         self.assertTrue(was_cancelled)
 
     def test_done_callback_raises(self):
-        LOGGER.removeHandler(STDERR_HANDLER)
-        logging_stream = io.StringIO()
-        handler = logging.StreamHandler(logging_stream)
-        LOGGER.addHandler(handler)
-        try:
+        with test.support.captured_stderr() as stderr:
             raising_was_called = False
             fn_was_called = False
 
@@ -655,10 +651,7 @@ class FutureTests(unittest.TestCase):
             f.set_result(5)
             self.assertTrue(raising_was_called)
             self.assertTrue(fn_was_called)
-            self.assertIn('Exception: doh!', logging_stream.getvalue())
-        finally:
-            LOGGER.removeHandler(handler)
-            LOGGER.addHandler(STDERR_HANDLER)
+            self.assertIn('Exception: doh!', stderr.getvalue())
 
     def test_done_callback_already_successful(self):
         callback_result = None