Skip to content

Commit

Permalink
Minor follow-up to previous commit
Browse files Browse the repository at this point in the history
Rewrote the code slightly to make
intentions more self explanatory.
  • Loading branch information
xolox committed Dec 9, 2020
1 parent ddd5aa3 commit 879105c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions coloredlogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,12 @@ def install(level=None, **kw):
use_colors = kw.get('isatty', None)
if use_colors or use_colors is None:
# Try to enable Windows native ANSI support or Colorama.
if on_windows():
use_colors = enable_ansi_support()
if on_windows() and not enable_ansi_support():
# This can fail, in which case ANSI escape sequences would end
# up being printed to the terminal in raw form. This is very
# user hostile, so to avoid this happening we disable color
# support on failure.
use_colors = False
# Disable ANSI escape sequences if 'stream' isn't connected
# to a terminal and no override (isatty=True) is used.
if use_colors is None:
Expand Down

0 comments on commit 879105c

Please sign in to comment.