https://github.com/python/cpython/commit/91e098f44dbb5b6533e5173ec9a819de4cae6660
commit: 91e098f44dbb5b6533e5173ec9a819de4cae6660
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: Yhg1s <[email protected]>
date: 2024-07-17T16:33:28Z
summary:

[3.13] gh-120678: Guard against stdin.fileno() being unavailable (GH-121924) 
(#121929)

gh-120678: Guard against stdin.fileno() being unavailable (GH-121924)
(cherry picked from commit 19cbf8fd636192059550d0c908c3e29797feed1f)

Co-authored-by: Ɓukasz Langa <[email protected]>

files:
M Lib/test/test_pyrepl/test_pyrepl.py

diff --git a/Lib/test/test_pyrepl/test_pyrepl.py 
b/Lib/test/test_pyrepl/test_pyrepl.py
index 6451d6104b5d1a..e6fcb69571c324 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -491,15 +491,23 @@ def prepare_reader(self, events):
 
     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"))

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to