-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Description
Bug report
Bug description:
It seems like the change in #139902 had other effects than what the PR intended. If those changes are intentional, it would be good if they were documented. And if they were not intentional, then this seem like a bug. This change has since been backported (#139902, #139903), though I don't believe those backports have been released.
Given the following code:
import textwrap
textwrap.wrap(' ABCDEFG', width=1)In 3.14.0, this returns [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G']
In 3.15.0a1, this returns ['A', 'B', 'C', 'D', 'E', 'F', 'G']
Since the PR only mentions trailing whitespace, it appears this change was unintended.
The documentation reads as follows.
drop_whitespace
(default: True) If true, whitespace at the beginning and ending of every line (after wrapping but before indenting) is dropped. Whitespace at the beginning of the paragraph, however, is not dropped if non-whitespace follows it. If whitespace being dropped takes up an entire line, the whole line is dropped.
I am not sure how to interpret this. This line would seem to indicate the space should be preserved.
Whitespace at the beginning of the paragraph, however, is not dropped if non-whitespace follows it.
CPython versions tested on:
3.15
Operating systems tested on:
Linux