From c9a4adb038bb69ac5f39bb9c39abec342ff955a6 Mon Sep 17 00:00:00 2001 From: "Michael V. DePalatis" Date: Mon, 5 Sep 2016 20:59:42 +0200 Subject: [PATCH] Only check if sys.stderr isatty once --- tornado/log.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tornado/log.py b/tornado/log.py index 86bb1485c..2ea0493ff 100644 --- a/tornado/log.py +++ b/tornado/log.py @@ -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 -- 2.47.2