Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitade6dea

Browse files
[3.14]gh-139065: Fix trailing space before long word in textwrap (GH-139070) (GH-139902)
Fix trailing space before a wrapped long word if the line length witha space is exactly "width".(cherry picked from commit1c598e0)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent08738ce commitade6dea

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

‎Lib/test/test_textwrap.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def test_break_long(self):
605605
# bug 1146. Prevent a long word to be wrongly wrapped when the
606606
# preceding word is exactly one character shorter than the width
607607
self.check_wrap(self.text,12,
608-
['Did you say',
608+
['Did you say',
609609
'"supercalifr',
610610
'agilisticexp',
611611
'ialidocious?',
@@ -633,7 +633,7 @@ def test_nobreak_long(self):
633633

634634
deftest_max_lines_long(self):
635635
self.check_wrap(self.text,12,
636-
['Did you say',
636+
['Did you say',
637637
'"supercalifr',
638638
'agilisticexp',
639639
'[...]'],

‎Lib/textwrap.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
211211

212212
# If we're allowed to break long words, then do so: put as much
213213
# of the next chunk onto the current line as will fit.
214-
ifself.break_long_words:
214+
ifself.break_long_wordsandspace_left>0:
215215
end=space_left
216216
chunk=reversed_chunks[-1]
217217
ifself.break_on_hyphensandlen(chunk)>space_left:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix trailing space before a wrapped long word if the line length is exactly
2+
*width* in:mod:`textwrap`.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp