Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Argparse wrapping is bugged when colors are involved #142035

Copy link
Copy link
@alexprengere

Description

@alexprengere
Issue body actions

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).

Image

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    Status
    Bugs
    Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.