Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix just_fix_windows_console to use the StreamWrapper #397

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rmccampbell
Copy link

The AnsiToWin32 class is not meant to be used as a file proxy directly, although it does define the write method, but it defines a stream member of type StreamWrapper which forwards/intercepts all the file operations as appropriate. In init which calls wrap_stream this underlying stream object is assigned to sys.stdout/stderr, but the just_fix_windows_console function instead assigns the AnsiToWin32 instance directly, which will break trying to use any other methods than write on the standard streams.

This change fixes the behavior of just_fix_windows_console to use the StreamWrapper object as in init.

The AnsiToWin32 class is not meant to be used as a file proxy directly, although it does define the write method, but it defines a `stream` member of type StreamWrapper which forwards/intercepts all the file operations as appropriate. In `init` which calls `wrap_stream` this underlying stream object is assigned to sys.stdout/stderr, but the `just_fix_windows_console` function instead assigns the AnsiToWin32 instance directly, which will break trying to use any other methods than `write` on the standard streams.

This change fixes the behavior of `just_fix_windows_console` to use the StreamWrapper object as in `init`.
@rmccampbell
Copy link
Author

I think properly testing this would require a pre-Windows 10 build of windows, so I have not actually tested it. IDK if colorama has some test workflow that would be able to actually verify it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant