Enable 3.13's colorized output (bot half) #3198
Merged
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.
One of the features new to Python 3.13 is the use of colored traceback output. These colors greatly aid in locating smaller bugs and are overall quite handy, but they are not always enabled, including for the bot's output message. This changes that.
Care was taken to achieve a significant degree of backwards compatibility. Long tracebacks, whose full forms are uploaded to pinnwand, go through a regular expression that removes ANSI escape codes. Pinnwand does not support ANSI, so if this is not done, the raw characters are included, easily making the traceback unintelligible. This will not delete escaped ANSI sequences, but it does provide a slight regression in that colored output that makes it to pinnwand is rendered monochrome (previously, the characters would be present, causing the legibility issue mentioned earlier - though whether this was a problem may be debated).
This PR is the bot side. There is a snekbox PR (python-discord/snekbox#225) that causes the colored output, which should probably be merged after this one.
This was not done alone. Credit is shared with
@ChrisLovering (for pointing to snekbox)
@shenanigansd and @parrrate (for help with docker)
@godlygeek (with the de-ANSIfication regex, much simpler than i thought it'd be)
paste mentioned in image is https://paste.pythondiscord.com/NEP7SBFPWJVETSCU5XJDLVG6Q4