Closed maartendp closed 4 years ago
I think we could also just modify the check elif sys.stdout.isatty() and not DISABLE_COLOR:
to be elif hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() and not DISABLE_COLOR:
In any case, this should definitely be an implicit check, not an explicit check, as I would not classify colored output in abnormal environments mission critical.
Even better :) thanks for the quick reply.
This is fixed in the new 0.4.0 release
Thank you for taking care of this so quickly. Very much appreciated!
Hi,
The
color_str
property is checking if the stdout is a tty by runningsys.stdout.isatty()
.In our case, a 3rd party populated the
sys.stdout
with an object that did not implementisatty
. Because of this, anAttributeError
was thrown when running the code incolor_str
. Python implicitly caught this and defaulted to getting the value from__getattr__
, which is, as you know, a function and indeed not a compatible type for printing.An implicit fix would be
An explicit fix would be
But I will leave it to your judgement to find the best approach.
Thanks for your time.