From 8c2b393c6848436b8cbc554147fabc447f4ce552 Mon Sep 17 00:00:00 2001 From: Jeff Quast Date: Sun, 12 Jan 2020 03:56:01 -0800 Subject: [PATCH] closes #59 use devnull for open descriptor --- blessed/terminal.py | 10 ++-------- docs/history.rst | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/blessed/terminal.py b/blessed/terminal.py index e066770e..f6b19514 100644 --- a/blessed/terminal.py +++ b/blessed/terminal.py @@ -212,15 +212,9 @@ def __init__(self, kind=None, stream=None, force_styling=False): self._kind = kind or os.environ.get('TERM', 'unknown') if self.does_styling: - # Initialize curses (call setupterm). - # - # Make things like tigetstr() work. Explicit args make setupterm() - # work even when -s is passed to nosetests. Lean toward sending - # init sequences to the stream if it has a file descriptor, and - # send them to stdout as a fallback, since they have to go - # somewhere. + # Initialize curses (call setupterm), so things like tigetstr() work. try: - curses.setupterm(self._kind, self._init_descriptor) + curses.setupterm(kind, open(os.devnull).fileno()) except curses.error as err: warnings.warn('Failed to setupterm(kind={0!r}): {1}' .format(self._kind, err)) diff --git a/docs/history.rst b/docs/history.rst index 6200768d..cc7898f9 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -18,6 +18,8 @@ Version History 24-bit color codes instead. * deprecated: additional key names, such as ``KEY_TAB``, are no longer "injected" into the curses module namespace. + * deprecated: :func:`curses.setupterm` is now called with :attr:`os.devnull` + as the file descriptor, let us know if this causes any issues. :ghissue:`59`. 1.16 * introduced: Windows support?! :ghissue:`110` by :ghuser:`avylove`.