Use new API for Windows: colorama.just_fix_windows_console() #1394
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tqdm uses colorama to enable proper ANSI support on Windows. Traditionally, it's done this by calling
colorama.init
. But this API is pretty awkward: it tries to do too much (e.g. guessing whether you have ANSI support and if not then installing sys.stdout/stderr filters that remove all ANSI codes from output -- even if the system actually does support ANSI!), and it isn't idempotent, so if multiple libraries all callcolorama.init
then you can get brokenness (in particular, it can trigger the situation where colorama thinks ANSI is unavailable, when it actually is!).To solve this, colorama 0.4.6 added a new API,
colorama.just_fix_windows_console
:tartley/colorama#352
The advantage of this is that it does what it says: it just fixes the Windows console, without any strange side-effects, and it's safe to call multiple times. The colorama maintainers are
recommending that everyone switch to it.