Merged revisions 62090-62091,62096,62100,62102,62110-62114 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r62090 | brett.cannon | 2008-04-01 07:37:43 -0500 (Tue, 01 Apr 2008) | 3 lines

  Generalize test.test_support.test_stdout() with a base context manager so that
  it is easy to capture stderr if desired.
........
  r62091 | brett.cannon | 2008-04-01 07:46:02 -0500 (Tue, 01 Apr 2008) | 3 lines

  Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
  of effort to do so.
........
  r62096 | amaury.forgeotdarc | 2008-04-01 17:52:48 -0500 (Tue, 01 Apr 2008) | 4 lines

  Newly enabled test appears to leak:
  it registers the same codec on each iteration.
  Do it only once at load time.
........
  r62100 | amaury.forgeotdarc | 2008-04-01 19:55:04 -0500 (Tue, 01 Apr 2008) | 4 lines

  A DocTestSuite cannot run multiple times: it clears its globals dictionary after the first run.

  Rebuild the DocTestSuite on each iteration.
........
  r62102 | jeffrey.yasskin | 2008-04-01 23:07:44 -0500 (Tue, 01 Apr 2008) | 3 lines

  Try to make test_signal less flaky.  I still see some flakiness in
  test_itimer_prof.
........
  r62110 | vinay.sajip | 2008-04-02 16:09:27 -0500 (Wed, 02 Apr 2008) | 1 line

  Fix: #2315, #2316, #2317: TimedRotatingFileHandler - changed logic to better handle daylight savings time, deletion of old log files, and fixed a bug in calculating rollover when no logging occurs for a longer interval than the rollover period.
........
  r62111 | vinay.sajip | 2008-04-02 16:10:23 -0500 (Wed, 02 Apr 2008) | 1 line

  Added updates with respect to recent changes to TimedRotatingFileHandler.
........
  r62112 | vinay.sajip | 2008-04-02 16:17:25 -0500 (Wed, 02 Apr 2008) | 1 line

  Added updates with respect to recent changes to TimedRotatingFileHandler.
........
  r62113 | amaury.forgeotdarc | 2008-04-02 16:18:46 -0500 (Wed, 02 Apr 2008) | 2 lines

  Remove debug prints; the buildbot now passes the tests
........
  r62114 | benjamin.peterson | 2008-04-02 16:20:35 -0500 (Wed, 02 Apr 2008) | 2 lines

  Suggested proposed changes to Python be considered on some mailing lists first
........
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index 3c039a1..8c12f57 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -28,6 +28,15 @@
     os._exit(0)
 
 
+def ignoring_eintr(__func, *args, **kwargs):
+    try:
+        return __func(*args, **kwargs)
+    except IOError as e:
+        if e.errno != signal.EINTR:
+            raise
+        return None
+
+
 class InterProcessSignalTests(unittest.TestCase):
     MAX_DURATION = 20   # Entire test should last at most 20 sec.
 
@@ -77,8 +86,11 @@
         if test_support.verbose:
             print("test runner's pid is", pid)
 
-        child = subprocess.Popen(['kill', '-HUP', str(pid)])
-        self.wait(child)
+        child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)])
+        if child:
+            self.wait(child)
+            if not self.a_called:
+                time.sleep(1)  # Give the signal time to be delivered.
         self.assertTrue(self.a_called)
         self.assertFalse(self.b_called)
         self.a_called = False
@@ -87,6 +99,7 @@
             child = subprocess.Popen(['kill', '-USR1', str(pid)])
             # This wait should be interrupted by the signal's exception.
             self.wait(child)
+            time.sleep(1)  # Give the signal time to be delivered.
             self.fail('HandlerBCalled exception not thrown')
         except HandlerBCalled:
             self.assertTrue(self.b_called)
@@ -94,8 +107,9 @@
             if test_support.verbose:
                 print("HandlerBCalled exception caught")
 
-        child = subprocess.Popen(['kill', '-USR2', str(pid)])
-        self.wait(child)  # Nothing should happen.
+        child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)])
+        if child:
+            self.wait(child)  # Nothing should happen.
 
         try:
             signal.alarm(1)
@@ -103,14 +117,18 @@
             # since alarm is going to raise a KeyboardException, which
             # will skip the call.
             signal.pause()
+            # But if another signal arrives before the alarm, pause
+            # may return early.
+            time.sleep(1)
         except KeyboardInterrupt:
             if test_support.verbose:
                 print("KeyboardInterrupt (the alarm() went off)")
         except:
-            self.fail('Some other exception woke us from pause: %s' %
+            self.fail("Some other exception woke us from pause: %s" %
                       traceback.format_exc())
         else:
-            self.fail('pause returned of its own accord')
+            self.fail("pause returned of its own accord, and the signal"
+                      " didn't arrive after another second.")
 
     def test_main(self):
         # This function spawns a child process to insulate the main