Closed Bug 1753851 Opened 3 years ago Closed 3 years ago

Initialize colorama on Windows

Categories

(Firefox Build System :: Mach Core, enhancement)

Unspecified
Windows
enhancement

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1744340

People

(Reporter: ahochheiden, Assigned: ahochheiden)

Details

Attachments

(1 obsolete file)

On Windows, in certain cases where STDOUT/STDERR output is captured from a subprocess, if it contains color information, it is not parsed correctly.

Example:
./mach python-test --subsuite=mozversioncontrol
Produces output like:

 0:21.70 python/mozversioncontrol/test/test_update.py::test_update[git] ←[32mPASSED←[0m
 0:21.70 python/mozversioncontrol/test/test_update.py::test_update[hg] ←[32mPASSED←[0m
 0:21.70
 0:21.72 ←[32m←[1m========================== 2 passed in 6.51 seconds ===========================←[0m
 0:21.72

The ←[32m is supposed to make subsequent text green. (See 32 under Text Formatting)

I discovered that initializing colorama before the loggers are created with sys.stdout solves this problem. It wraps the sys.stdout write() and that makes all subsequent writes on all logger streams correctly parse/interpret the color sequences.

I think the intent of this ticket is captured by the "fix color output of Mach" bug.
Also, fwiw, in general I'd recommend describing tickets by what they'll improve, rather than the implementation change (if possible).
There will be things that are super implementation specific (e.g. "move x11 detection to python configure"), but I think this work has a real user-perceptible bug that we should refer to instead.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
Attachment #9262527 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: