Skip to content

argparse indentation overshoots due to colors #139736

Closed

Description

@9001

Bug report

Bug description:

As of 3.14, argparse --help accidentally includes the ansi-escapes when calculating the length of the invocations, resulting in excessive margins between options and their helptext. Effectively, the indentation will always be 24 (max_help_position).

import argparse
argparse.ArgumentParser().print_help()

in 3.14, this produces:

options:
  -h, --help            show this help message and exit

in previous versions, it produces:

options:
  -h, --help  show this help message and exit

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Oct 7, 2025
  2. added a commit that references this issue on Oct 7, 2025
  3. added
    stdlibStandard Library Python modules in the Lib/ directory
    3.14bugs and security fixes
    on Oct 7, 2025
  4. added a commit that references this issue on Oct 8, 2025
  5. added a commit that references this issue on Oct 8, 2025
  6. added a commit that references this issue on Oct 8, 2025
  7. added a commit that references this issue on Oct 8, 2025
  8. hugovk commented on Oct 8, 2025

    @hugovk
    Member

    Thanks for the report and fix!

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.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions