]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-120678: Guard against stdin.fileno() being unavailable (GH-121924) (#121929)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 17 Jul 2024 16:33:28 +0000 (18:33 +0200)
committerGitHub <noreply@github.com>
Wed, 17 Jul 2024 16:33:28 +0000 (16:33 +0000)
gh-120678: Guard against stdin.fileno() being unavailable (GH-121924)
(cherry picked from commit 19cbf8fd636192059550d0c908c3e29797feed1f)

Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Lib/test/test_pyrepl/test_pyrepl.py

index 6451d6104b5d1af33899cbcb5e0c275d941478c5..e6fcb69571c3247ef0420d70ada3684e98bf26ab 100644 (file)
@@ -491,15 +491,23 @@ class TestPyReplOutput(TestCase):
 
     def test_stdin_is_tty(self):
         # Used during test log analysis to figure out if a TTY was available.
-        if os.isatty(sys.stdin.fileno()):
-            return
-        self.skipTest("stdin is not a tty")
+        try:
+            if os.isatty(sys.stdin.fileno()):
+                return
+        except OSError as ose:
+            self.skipTest(f"stdin tty check failed: {ose}")
+        else:
+            self.skipTest("stdin is not a tty")
 
     def test_stdout_is_tty(self):
         # Used during test log analysis to figure out if a TTY was available.
-        if os.isatty(sys.stdout.fileno()):
-            return
-        self.skipTest("stdout is not a tty")
+        try:
+            if os.isatty(sys.stdout.fileno()):
+                return
+        except OSError as ose:
+            self.skipTest(f"stdout tty check failed: {ose}")
+        else:
+            self.skipTest("stdout is not a tty")
 
     def test_basic(self):
         reader = self.prepare_reader(code_to_events("1+1\n"))