From 81b4b0a502f0e8d1c3ea7a2e5810552106eb0e6e Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 17 Jul 2024 19:03:04 +0300 Subject: [PATCH] gh-121927: Fix `io.UnsupportedOperation: fileno` exception in `test_pyrepl` --- Lib/test/test_pyrepl/test_pyrepl.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 6451d6104b5d1a..b6450156113685 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -491,14 +491,24 @@ 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 + try: + fileno = sys.stdin.fileno() + except OSError: + pass + else: + if os.isatty(fileno): + return 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 + try: + fileno = sys.stdout.fileno() + except OSError: + pass + else: + if os.isatty(fileno): + return self.skipTest("stdout is not a tty") def test_basic(self):