summaryrefslogtreecommitdiffstats
path: root/Lib/_colorize.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/_colorize.py')
-rw-r--r--Lib/_colorize.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/_colorize.py b/Lib/_colorize.py
index 845fb57..709081e 100644
--- a/Lib/_colorize.py
+++ b/Lib/_colorize.py
@@ -32,14 +32,6 @@ def get_colors(colorize: bool = False) -> ANSIColors:
def can_colorize() -> bool:
- if sys.platform == "win32":
- try:
- import nt
-
- if not nt._supports_virtual_terminal():
- return False
- except (ImportError, AttributeError):
- return False
if not sys.flags.ignore_environment:
if os.environ.get("PYTHON_COLORS") == "0":
return False
@@ -58,6 +50,15 @@ def can_colorize() -> bool:
if not hasattr(sys.stderr, "fileno"):
return False
+ if sys.platform == "win32":
+ try:
+ import nt
+
+ if not nt._supports_virtual_terminal():
+ return False
+ except (ImportError, AttributeError):
+ return False
+
try:
return os.isatty(sys.stderr.fileno())
except io.UnsupportedOperation: