summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Rose <grinch@grinchcentral.com>2018-09-07 09:15:23 -0400
committerGitHub <noreply@github.com>2018-09-07 09:15:23 -0400
commit3f59001a1d40d53a33645ac7478a841b0d03d80d (patch)
treef2eae2b9d113812d050ced4dd7601c2f469904a4
parentaf6b7b8773c2ff098bce112229913dee90928bfa (diff)
parentd885df78c6f931abf3259343aaaa897e16c8cba1 (diff)
downloadblessings-3f59001a1d40d53a33645ac7478a841b0d03d80d.tar.gz
Merge fix for crash when $TERM is bad. Fix #39. Close #137.
-rw-r--r--blessings/__init__.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/blessings/__init__.py b/blessings/__init__.py
index 98b75c3..fdceb09 100644
--- a/blessings/__init__.py
+++ b/blessings/__init__.py
@@ -94,8 +94,13 @@ class Terminal(object):
# 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.
- setupterm(kind or environ.get('TERM', 'unknown'),
- self._init_descriptor)
+ try:
+ setupterm(kind or environ.get('TERM', 'dumb'),
+ self._init_descriptor)
+ except curses.error:
+ # There was an error setting up the terminal, either curses is
+ # not supported or TERM is incorrectly set. Fall back to dumb.
+ self._does_styling = False
self.stream = stream