Bug report
Bug description:
While working on coloring interpolated values in #141940, I realized that in some cases the wrapping is broken.
For example in this case, just a color change around the commas makes the wrapping different, because textwrap.wrap is sensitive to ANSI escape codes (those change the string length).
There are 2 ways to fix this:
- have a more clever wrapping that is not sensitive to ANSI escape codes
- make sure the wrapping always happens before ANSI escape codes are inserted
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-142035: Textwrap without ansi escapes #142040
- gh-154686: Add
text_lentoTextWrapper#152702 - GH-142035: Fix wrapping of colorized argparse help text #154634
- [3.15] GH-142035: Fix wrapping of colorized argparse help text (GH-154634) #154644
- [3.14] GH-142035: Fix wrapping of colorized argparse help text (GH-154634) #154645
- [3.15] GH-142035: Fix wrapping of colorized argparse help text (GH-15… #154646
