Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repair colorama wrapping on non-Windows platforms
The wrap_stream_for_windows() function calls colorama.initialise.wrap_stream() function to apply colorama's magic to wrapper to the output stream. Except this wrapper is only applied on Windows platforms that need it, otherwise the original stream is returned as-is. The colorama wrapped stream lacks a detach() method, so a no-op lambda was being assigned to the wrapped stream. The problem is that the no-op lambda was being assigned unconditionally whether or not colorama actually returns a wrapped stream, thus replacing the original TextIOWrapper's detach() method. Replacing the detach() method with a no-op lambda is the root cause of the problem observed in psf#1664. The solution is to only assign the no-op detach() method if the stream lacks its own detach() method. Repairs psf#1664
- Loading branch information