From: Michael V. DePalatis Date: Mon, 5 Sep 2016 18:59:42 +0000 (+0200) Subject: Only check if sys.stderr isatty once X-Git-Tag: v4.5.0~22^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9a4adb038bb69ac5f39bb9c39abec342ff955a6;p=thirdparty%2Ftornado.git Only check if sys.stderr isatty once --- 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