https://github.com/python/cpython/commit/eacb85a2b2ee9212997ab451dc95ec3e7992afc8 commit: eacb85a2b2ee9212997ab451dc95ec3e7992afc8 branch: main author: Serhiy Storchaka <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2026-07-09T15:43:26Z summary:
gh-90092: Fix test_curses when stdin is write-only (e.g. under nohup) (GH-153420) newterm() needs a readable input fd, but nohup can leave stdin write-only. Fall back to the output fd, as already done when stdin has no fileno. Co-authored-by: Claude Opus 4.8 <[email protected]> files: M Lib/test/test_curses.py diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index f54c9a62d5033e..870393be5209df 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -29,6 +29,9 @@ except ImportError: pass +# Only reachable once curses imported, so the platform has fcntl too. +import fcntl + def requires_curses_func(name): return unittest.skipUnless(hasattr(curses, name), 'requires curses.%s' % name) @@ -164,6 +167,10 @@ def setUp(self): # ScreenTests run newterm()/set_term() in the same process. try: infd = sys.__stdin__.fileno() + if fcntl.fcntl(infd, fcntl.F_GETFL) & os.O_ACCMODE == os.O_WRONLY: + # newterm() needs a readable input fd; a write-only stdin + # (as nohup leaves for a backgrounded run) fails with EINVAL. + infd = stdout_fd except (AttributeError, ValueError, OSError): infd = stdout_fd self.screen = curses.newterm(term, stdout_fd, infd) _______________________________________________ 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]
