]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118908: Protect the REPL subprocess with a timeout in tests (#120408)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Wed, 12 Jun 2024 19:09:25 +0000 (20:09 +0100)
committerGitHub <noreply@github.com>
Wed, 12 Jun 2024 19:09:25 +0000 (19:09 +0000)
Lib/test/test_pyrepl/test_pyrepl.py

index 3167b8473bfe2093613551cf364e4a2cf5e3eb1f..41ba5959a1ec34ee614652a07e96550cc7ae6abe 100644 (file)
@@ -8,6 +8,7 @@ import sys
 from unittest import TestCase, skipUnless
 from unittest.mock import patch
 from test.support import force_not_colorized
+from test.support import SHORT_TIMEOUT
 
 from .support import (
     FakeConsole,
@@ -885,5 +886,9 @@ class TestMain(TestCase):
 
         os.close(master_fd)
         os.close(slave_fd)
-        exit_code = process.wait()
+        try:
+            exit_code = process.wait(timeout=SHORT_TIMEOUT)
+        except subprocess.TimeoutExpired:
+            process.kill()
+            exit_code = process.returncode
         return "\n".join(output), exit_code