Skip to content

Commit f96c9af

Browse files
committed
Debug buildbot colorization
1 parent 68c7fad commit f96c9af

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Lib/_colorize.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,19 +430,25 @@ def _safe_getenv(k: str, fallback: str | None = None) -> str | None:
430430
file = sys.stdout
431431

432432
if not sys.flags.ignore_environment:
433+
print("== PYTHON_COLORS", _safe_getenv("PYTHON_COLORS"))
433434
if _safe_getenv("PYTHON_COLORS") == "0":
434435
return False
435436
if _safe_getenv("PYTHON_COLORS") == "1":
436437
return True
438+
print("== NO_COLOR", _safe_getenv("NO_COLOR"))
437439
if _safe_getenv("NO_COLOR"):
438440
return False
441+
print("== COLORIZE", COLORIZE)
439442
if not COLORIZE:
440443
return False
444+
print("== FORCE_COLOR", _safe_getenv("FORCE_COLOR"))
441445
if _safe_getenv("FORCE_COLOR"):
442446
return True
447+
print("== TERM", _safe_getenv("TERM"))
443448
if _safe_getenv("TERM") == "dumb":
444449
return False
445450

451+
print('== hasattr(file, "fileno")', hasattr(file, "fileno"))
446452
if not hasattr(file, "fileno"):
447453
return False
448454

@@ -455,6 +461,11 @@ def _safe_getenv(k: str, fallback: str | None = None) -> str | None:
455461
except (ImportError, AttributeError):
456462
return False
457463

464+
try:
465+
print('== os.isatty(file.fileno())', os.isatty(file.fileno()))
466+
except OSError:
467+
print("== os.isatty(file.fileno()) Failed")
468+
print('== hasattr(file, "isatty") and file.isatty()', hasattr(file, "isatty") and file.isatty())
458469
try:
459470
return os.isatty(file.fileno())
460471
except OSError:

0 commit comments

Comments
 (0)