[Python-checkins] r87556 - in python/branches/py3k/Lib: concurrent/futures/_base.py test/test_concurrent_futures.py

brian.quinlan python-checkins at python.org
Tue Dec 28 22:14:34 CET 2010


Author: brian.quinlan
Date: Tue Dec 28 22:14:34 2010
New Revision: 87556

Log:
Does not install a logging handler. Fixes issue 10626.

Modified:
   python/branches/py3k/Lib/concurrent/futures/_base.py
   python/branches/py3k/Lib/test/test_concurrent_futures.py

Modified: python/branches/py3k/Lib/concurrent/futures/_base.py
==============================================================================
--- python/branches/py3k/Lib/concurrent/futures/_base.py	(original)
+++ python/branches/py3k/Lib/concurrent/futures/_base.py	Tue Dec 28 22:14:34 2010
@@ -41,8 +41,6 @@
 
 # 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."""

Modified: python/branches/py3k/Lib/test/test_concurrent_futures.py
==============================================================================
--- python/branches/py3k/Lib/test/test_concurrent_futures.py	(original)
+++ python/branches/py3k/Lib/test/test_concurrent_futures.py	Tue Dec 28 22:14:34 2010
@@ -24,7 +24,7 @@
 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 @@
         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 @@
             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


More information about the Python-checkins mailing list