FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-90092: Fix test_curses when stdin is write-only (e.g. under nohup) by serhiy-storchaka · Pull Request #153420 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions Lib/test/test_curses.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading

Back | FazBrowse Home | New Git URL