Visitar URL original
gh-56708: support custom len function in textwrap.wrap by xi · Pull Request #28136 · python/cpython · GitHub
Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'main' into textwrap-len
  • Loading branch information
serhiy-storchaka committed Dec 8, 2025
commit 95fcafdb5995f24bc0978e94a40be8d68940a1ff
3 changes: 2 additions & 1 deletion Lib/textwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):

# If we're allowed to break long words, then do so: put as much
# of the next chunk onto the current line as will fit.
if self.break_long_words:
if self.break_long_words and space_left > 0:
end = space_left
chunk = reversed_chunks[-1]
end = self._find_width_index(chunk, space_left)
if self.break_on_hyphens and self.text_len(chunk) > space_left:
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.