Skip to content

textwrap can leave a trailing space before long word #139065

@serhiy-storchaka

Description

@serhiy-storchaka

Bug report

>>> textwrap.wrap('Did you say "supercalifragilisticexpialidocious?" How *do* you spell that odd word, anyways?', 12)
['Did you say ', '"supercalifr', 'agilisticexp', 'ialidocious?', '" How *do*', 'you spell', 'that odd', 'word,', 'anyways?']

Note a trailing space in the first line. No trailing spaces in other lines.

This is even in the tests, but I do not think it is an intentional behavior. The bug was introduced in the fix for:

Linked PRs

Metadata

Metadata

Labels

3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions