Skip to content

Commit 973d549

Browse files
[3.11] gh-110033: Fix signal test_interprocess_signal() (GH-110035) (#110041)
gh-110033: Fix signal test_interprocess_signal() (GH-110035) Fix test_interprocess_signal() of test_signal. Make sure that the subprocess.Popen object is deleted before the test raising an exception in a signal handler. Otherwise, Popen.__del__() can get the exception which is logged as "Exception ignored in: ...." and the test fails. (cherry picked from commit 7e0fbf5) Co-authored-by: Victor Stinner <[email protected]>
1 parent ff3cadd commit 973d549

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Lib/test/signalinterproctester.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gc
12
import os
23
import signal
34
import subprocess
@@ -60,6 +61,13 @@ def test_interprocess_signal(self):
6061
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 0,
6162
'SIGALRM': 0})
6263

64+
# gh-110033: Make sure that the subprocess.Popen is deleted before
65+
# the next test which raises an exception. Otherwise, the exception
66+
# may be raised when Popen.__del__() is executed and so be logged
67+
# as "Exception ignored in: <function Popen.__del__ at ...>".
68+
child = None
69+
gc.collect()
70+
6371
with self.assertRaises(SIGUSR1Exception):
6472
with self.subprocess_send_signal(pid, "SIGUSR1") as child:
6573
self.wait_signal(child, 'SIGUSR1')
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fix ``test_interprocess_signal()`` of ``test_signal``. Make sure that the
2+
``subprocess.Popen`` object is deleted before the test raising an exception
3+
in a signal handler. Otherwise, ``Popen.__del__()`` can get the exception
4+
which is logged as ``Exception ignored in: ...`` and the test fails. Patch by
5+
Victor Stinner.

0 commit comments

Comments
 (0)