]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-110033: Fix signal test_interprocess_signal() (GH-110035) (#110040)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 2 Oct 2023 15:42:40 +0000 (08:42 -0700)
committerGitHub <noreply@github.com>
Mon, 2 Oct 2023 15:42:40 +0000 (17:42 +0200)
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 7e0fbf5175fcf21dae390ba68b7f49706d62aa49)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/signalinterproctester.py
Misc/NEWS.d/next/Tests/2023-09-28-18-14-52.gh-issue-110033.2yHMx0.rst [new file with mode: 0644]

index cdcd92a8baace6bab718e08ecf17e84cc0bbaa1c..073c078f45f6d722c041c40d164f848e3d59f291 100644 (file)
@@ -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 (file)
index 0000000..fb60893
--- /dev/null
@@ -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.