From: Jelle Zijlstra Date: Fri, 17 Dec 2021 17:25:41 +0000 (-0800) Subject: Handle curses.tigetstr() returning None X-Git-Tag: v6.2.0b1~33^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3094%2Fhead;p=thirdparty%2Ftornado.git Handle curses.tigetstr() returning None Found with python/typeshed#6620 --- diff --git a/tornado/log.py b/tornado/log.py index 810a0373b..869989613 100644 --- a/tornado/log.py +++ b/tornado/log.py @@ -151,7 +151,11 @@ class LogFormatter(logging.Formatter): self._colors[levelno] = unicode_type( curses.tparm(fg_color, code), "ascii" ) - self._normal = unicode_type(curses.tigetstr("sgr0"), "ascii") + normal = curses.tigetstr("sgr0") + if normal is not None: + self._normal = unicode_type(normal, "ascii") + else: + self._normal = "" else: # If curses is not present (currently we'll only get here for # colorama on windows), assume hard-coded ANSI color codes.