https://github.com/erikrose/blessings/pull/137

Fixes: https://bugs.gentoo.org/654316

From 5fefc65c306cf9ec492e7b422d6bb4842385afbc
[PATCH 1/2] Fix error when TERM is unset or improperly set

From d885df78c6f931abf3259343aaaa897e16c8cba1
[PATCH 2/2] Explicitly catch curses.error


--- a/third_party/python/blessings/blessings/__init__.py
+++ b/third_party/python/blessings/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') or '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
 
