diff options
author | Jay Kamat <jaygkamat@gmail.com> | 2018-08-24 11:11:57 -0700 |
---|---|---|
committer | Jay Kamat <jgkamat@fb.com> | 2018-08-24 11:35:40 -0700 |
commit | 5fefc65c306cf9ec492e7b422d6bb4842385afbc (patch) | |
tree | 21216b38153bde4efac5a006e216264648a3457a /blessings | |
parent | 0b81fe09469b6743e7467f6894dc036069c3a876 (diff) | |
download | blessings-5fefc65c306cf9ec492e7b422d6bb4842385afbc.tar.gz |
Fix error when TERM is unset or improperly set
Diffstat (limited to 'blessings')
-rw-r--r-- | blessings/__init__.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/blessings/__init__.py b/blessings/__init__.py index 98b75c3..3872b5f 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: + # 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 |