Skip to content

Unable to force color output on Windows #127353

Description

@PalmtopTiger

Bug report

Bug description:

In can_colorize function, nt._supports_virtual_terminal call takes precedence over checking of environment variables. If the terminal emulator does not support this mode, the environment variables are not checked. This is contrary to the behavior on POSIX OSes, where variables are checked first.

There are third-party terminal emulators that support ANSI color codes, but do not support the new API added in Windows 10. For example, ConEmu and Cmder.

Also, the current behavior makes it impossible to output errors with ANSI codes to a file or through a pipe.

Screenshot of exception in ConEmu terminal:
241128153324_unp

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixesOS-windowsstdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions