This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.moore
Recipients daverove, paul.moore, steve.dower, tim.golden, zach.ware
Date 2020-04-01.16:15:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585757717.27.0.0418963495675.issue40134@roundup.psfhosted.org>
In-reply-to
Content
This works fine for me in Windows terminal, but I see the behaviour described when using the conventional "Command prompt" window.

Enabling ANSI codes is handled via SetConsoleMode (see here: https://docs.microsoft.com/en-us/windows/console/setconsolemode). The following proof of concept script correctly displays coloured text:

    from ctypes import *
    kernel32 = windll.kernel32
    kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
    ansi_red = "\x1b[31m"
    ansi_normal = "\x1b[0m"
    print(ansi_red + "This is red!" + ansi_normal)

Agreed this would be worthwhile setting on stdout by default. The code at https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example-of-enabling-virtual-terminal-processing seems to be an example of how to do this while still supporting older systems
History
Date User Action Args
2020-04-01 16:15:17paul.mooresetrecipients: + paul.moore, tim.golden, zach.ware, steve.dower, daverove
2020-04-01 16:15:17paul.mooresetmessageid: <1585757717.27.0.0418963495675.issue40134@roundup.psfhosted.org>
2020-04-01 16:15:17paul.moorelinkissue40134 messages
2020-04-01 16:15:17paul.moorecreate