alliedmodders / ambuild

AlliedModders C++ Build System
BSD 3-Clause "New" or "Revised" License
61 stars 32 forks source link

Fix colored text on Windows when using Python 3.x. #66

Closed TheDS closed 5 years ago

TheDS commented 5 years ago

If you run AMBuild on Windows using Python 3, text is not being colored. It works fine with Python 2, however.

This is because IO buffering is handled differently between Python 2 and Python 3. In Python 2, stdout is unbuffered by default (in a tty) because that's how the CRT handles it. Python 3 does its own buffering which appears to be line buffered by default.

This is discussed in this Python bug report: https://bugs.python.org/issue11633

So because it's line buffered, only the last call per line to SetConsoleTextAttribute has any effect which is often just the default text color (ConsoleNormal).

KyleSanderson commented 5 years ago

This is likely the sigpipe issue we've had for years too as a byproduct.

dvander commented 5 years ago

It's not, that was fixed with https://github.com/alliedmodders/ambuild/commit/21ada6b05646b5df58102a766cea6691efda1350