]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Only check if sys.stderr isatty once
authorMichael V. DePalatis <mike@depalatis.net>
Mon, 5 Sep 2016 18:59:42 +0000 (20:59 +0200)
committerMichael V. DePalatis <mike@depalatis.net>
Mon, 5 Sep 2016 18:59:42 +0000 (20:59 +0200)
tornado/log.py

index 86bb1485cb86fd9c996e3eacb4857b9c39ce946b..2ea0493ff965f4176cf5ac167f327931f58b49b7 100644 (file)
@@ -57,15 +57,16 @@ gen_log = logging.getLogger("tornado.general")
 
 def _stderr_supports_color():
     color = False
-    if curses and hasattr(sys.stderr, 'isatty') and sys.stderr.isatty():
-        try:
-            curses.setupterm()
-            if curses.tigetnum("colors") > 0:
-                color = True
-        except Exception:
-            pass
-    elif colorama and os.isatty(sys.stderr.fileno()):
-        color = True
+    if hasattr(sys.stderr, 'isatty') and sys.stderr.isatty():
+        if curses:
+            try:
+                curses.setupterm()
+                if curses.tigetnum("colors") > 0:
+                    color = True
+            except Exception:
+                pass
+        elif colorama:
+            color = True
     return color