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

Support python-2.7 in enable_vt_processing #364

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

donkopotamus
Copy link
Contributor

This fixes an issue present in colorama-0.4.6 when run in python-2.7 on msys or git-bash terminals (such as mintty). In such a case the following error has been observed

  File "C:\...\.venv\lib\site-packages\click\core.py", line 950, in show_help
    echo(ctx.get_help(), color=ctx.color)
  File "C:\...\.venv\lib\site-packages\click\utils.py", line 267, in echo
    file = auto_wrap_for_ansi(file)
  File "C:\...\.venv\lib\site-packages\click\_compat.py", line 704, in auto_wrap_for_ansi
    ansi_wrapper = colorama.AnsiToWin32(stream, strip=strip)
  File "C:\...\.venv\lib\site-packages\colorama\ansitowin32.py", line 101, in __init__
    system_has_native_ansi = not on_windows or enable_vt_processing(fd)
  File "C:\...\.venv\lib\site-packages\colorama\winterm.py", line 183, in enable_vt_processing
    handle = get_osfhandle(fd)
IOError: [Errno 9] Bad file descriptor

Note that this does not occur in python-3, as in such a case an IOError is really an OSError and is then caught.

In `python-2.7`, when running in `msys` or `git-bash` based terminals, calls to `enable_vt_processing` will fail with an `IOError`
@njsmith
Copy link
Collaborator

njsmith commented Nov 2, 2022

Doh, I forgot about that. Thanks for the catch!

@njsmith njsmith merged commit 4349173 into tartley:master Nov 2, 2022
@njsmith njsmith mentioned this pull request Nov 21, 2022
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.

None yet

2 participants