From 5dae085fad5dcca45b69bf99b97bb7c6b61f23fa Mon Sep 17 00:00:00 2001 From: Robert Rollins Date: Wed, 4 Aug 2021 12:34:31 -0700 Subject: [PATCH] Added check to ensure init() will only have any effect in Windows. --- colorama/initialise.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/colorama/initialise.py b/colorama/initialise.py index 430d0668..80e3619d 100644 --- a/colorama/initialise.py +++ b/colorama/initialise.py @@ -25,6 +25,12 @@ def init(autoreset=False, convert=None, strip=None, wrap=True): if not wrap and any([autoreset, convert, strip]): raise ValueError('wrap=False conflicts with any other arg=True') + # This function is only intended to have any effect when it's run on Windows. + # To ensure that unexpected side effects do not occur on any other platform, + # we return immediately if not running on Windows. + if sys.platform != 'win32': + return + global wrapped_stdout, wrapped_stderr global orig_stdout, orig_stderr