Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91e098f

Browse files
miss-islingtonambv
andauthored
[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 19cbf8f) Co-authored-by: Łukasz Langa <[email protected]>
1 parent ea36420 commit 91e098f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,23 @@ def prepare_reader(self, events):
491491

492492
def test_stdin_is_tty(self):
493493
# Used during test log analysis to figure out if a TTY was available.
494-
if os.isatty(sys.stdin.fileno()):
495-
return
496-
self.skipTest("stdin is not a tty")
494+
try:
495+
if os.isatty(sys.stdin.fileno()):
496+
return
497+
except OSError as ose:
498+
self.skipTest(f"stdin tty check failed: {ose}")
499+
else:
500+
self.skipTest("stdin is not a tty")
497501

498502
def test_stdout_is_tty(self):
499503
# Used during test log analysis to figure out if a TTY was available.
500-
if os.isatty(sys.stdout.fileno()):
501-
return
502-
self.skipTest("stdout is not a tty")
504+
try:
505+
if os.isatty(sys.stdout.fileno()):
506+
return
507+
except OSError as ose:
508+
self.skipTest(f"stdout tty check failed: {ose}")
509+
else:
510+
self.skipTest("stdout is not a tty")
503511

504512
def test_basic(self):
505513
reader = self.prepare_reader(code_to_events("1+1\n"))

0 commit comments

Comments
 (0)