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):