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
Next Next commit
fix missing len occurences
  • Loading branch information
xi committed Sep 3, 2021
commit f457e20d835bc5099da512fb621b64ea887306ef
4 changes: 2 additions & 2 deletions Lib/textwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def _wrap_chunks(self, chunks):
del chunks[-1]

while chunks:
l = len(chunks[-1])
l = self.text_len(chunks[-1])

# Can at least squeeze this chunk onto the current line.
if cur_len + l <= width:
Expand All @@ -304,7 +304,7 @@ def _wrap_chunks(self, chunks):

# The current line is full, and the next chunk is too big to
# fit on *any* line (not just this one).
if chunks and len(chunks[-1]) > width:
if chunks and self.text_len(chunks[-1]) > width:
self._handle_long_word(chunks, cur_line, cur_len, width)
cur_len = sum(map(self.text_len, cur_line))

Expand Down