]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Handle curses.tigetstr() returning None 3094/head
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Fri, 17 Dec 2021 17:25:41 +0000 (09:25 -0800)
committerGitHub <noreply@github.com>
Fri, 17 Dec 2021 17:25:41 +0000 (09:25 -0800)
Found with python/typeshed#6620

tornado/log.py

index 810a0373b503166be38547febee9186add1f5c39..86998961397bd2970755f87c02049a62fa34a76a 100644 (file)
@@ -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.