summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-09-28 17:12:11 (GMT)
committerGitHub <noreply@github.com>2023-09-28 17:12:11 (GMT)
commit7e0fbf5175fcf21dae390ba68b7f49706d62aa49 (patch)
treeb29e5fc356af063a4bb5cb3f146c2a5e6e48f082
parent757cbd4f29c9e89b38b975e0463dc8ed331b2515 (diff)
downloadcpython-7e0fbf5175fcf21dae390ba68b7f49706d62aa49.zip
cpython-7e0fbf5175fcf21dae390ba68b7f49706d62aa49.tar.gz
cpython-7e0fbf5175fcf21dae390ba68b7f49706d62aa49.tar.bz2
gh-110033: Fix signal test_interprocess_signal() (#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.
-rw-r--r--Lib/test/signalinterproctester.py8
-rw-r--r--Misc/NEWS.d/next/Tests/2023-09-28-18-14-52.gh-issue-110033.2yHMx0.rst5
2 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/signalinterproctester.py b/Lib/test/signalinterproctester.py
index cdcd92a..073c078 100644
--- a/Lib/test/signalinterproctester.py
+++ b/Lib/test/signalinterproctester.py
@@ -1,3 +1,4 @@
+import gc
import os
import signal
import subprocess
@@ -59,6 +60,13 @@ class InterProcessSignalTests(unittest.TestCase):
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 0,
'SIGALRM': 0})
+ # gh-110033: Make sure that the subprocess.Popen is deleted before
+ # the next test which raises an exception. Otherwise, the exception
+ # may be raised when Popen.__del__() is executed and so be logged
+ # as "Exception ignored in: <function Popen.__del__ at ...>".
+ child = None
+ gc.collect()
+
with self.assertRaises(SIGUSR1Exception):
with self.subprocess_send_signal(pid, "SIGUSR1") as child:
self.wait_signal(child, 'SIGUSR1')
diff --git a/Misc/NEWS.d/next/Tests/2023-09-28-18-14-52.gh-issue-110033.2yHMx0.rst b/Misc/NEWS.d/next/Tests/2023-09-28-18-14-52.gh-issue-110033.2yHMx0.rst
new file mode 100644
index 0000000..fb60893
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2023-09-28-18-14-52.gh-issue-110033.2yHMx0.rst
@@ -0,0 +1,5 @@
+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. Patch by
+Victor Stinner.