Skip to content

Commit 02d14ac

Browse files
committed
pythongh-110033: Fix signal test_interprocess_signal()
Make sure that the subprocess.Popen object is deleted before the test running an exception in a signal handler. Otherwise, Popen.__del__() can get the exception which is logged as "Exception ignored in: ...".
1 parent 7df8b16 commit 02d14ac

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎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
@@ -59,6 +60,13 @@ def test_interprocess_signal(self):
5960
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 0,
6061
'SIGALRM': 0})
6162

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

0 commit comments

Comments
 (0)