Uh oh!
There was an error while loading. Please reload this page.
gh-154686: Add text_len to TextWrapper - #152702
Open
kdeldycke wants to merge 1 commit into
Open
Conversation
kdeldycke
requested review from
AA-Turner, savannahostrowski and terryjreedy
as code ownersJune 30, 2026 15:34
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
This was referenced Jun 30, 2026
kdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jun 30, 2026
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
June 30, 2026 15:37
21c6877 to
4497db3CompareMost changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
kdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jun 30, 2026
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
June 30, 2026 15:40
4497db3 to
baba0c5Compare
This was referenced Jun 30, 2026
kdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jun 30, 2026
# Conflicts: # Doc/whatsnew/3.16.rst
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
June 30, 2026 16:06
baba0c5 to
36a27acComparekdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jun 30, 2026
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
June 30, 2026 16:07
36a27ac to
ac1a642Comparekdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jun 30, 2026
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
June 30, 2026 16:10
ac1a642 to
090c887CompareTextWrapper ANSI-awareTextWrapper ANSI-awareDocumentation build overview
149 files changed · |
merwok
reviewed
Jul 13, 2026
Uh oh!
There was an error while loading. Please reload this page.
merwok
reviewed
Jul 13, 2026
Uh oh!
There was an error while loading. Please reload this page.
kdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jul 15, 2026
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
July 15, 2026 23:34
8327c94 to
ba63d75Comparekdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jul 15, 2026
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
July 15, 2026 23:45
219db60 to
8e3c15aComparekdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jul 25, 2026
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
July 25, 2026 09:49
8e3c15a to
3cdc69fCompareTextWrapper ANSI-awareTextWrapper ANSI-awareTextWrapper ANSI-awaretext_len to TextWrapperkdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jul 25, 2026
For ANSI and variable character width awareness. Removes local patch introduced in python#154634.
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
July 25, 2026 10:19
3cdc69f to
847d242Comparekdeldycke added a commit
to kdeldycke/cpython
that referenced
this pull request
Jul 25, 2026
For ANSI and variable character width awareness. Removes local patch introduced in python#154634.
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
July 25, 2026 11:47
847d242 to
1497de0CompareFor ANSI and variable character width awareness. Removes local patch introduced in python#154634.
kdeldyckeforce-pushed
the
ANSI-aware-TextWrapper
branch
from
July 31, 2026 16:48
4f1e56d to
27b653dCompare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Add a
text_lenparameter totextwrap.wrap,textwrap.fill,textwrap.shortenandtextwrap.TextWrapper. It customizes how the visible width of a string is measured, so text that contains zero-width or double-width characters, or invisible ANSI escape sequences, can be wrapped correctly.This has the side effect of removing the local patch in
_split_linesintroduced by #154634 .Context
I am a maintainer of Click and had to maintain my own local fork of
TextWrapperto make it strip ANSI strings properly. See my initial code at: pallets/click#3420 . This PR is a direct port of that code to Python standard library.This PR:
text_lentoTextWrapperfor ANSI and variable character width awareness #154686text_lentoTextWrapperfor ANSI and variable character width awareness #154686