Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion Lib/textwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ def dedent(text):
if not text:
return text

lines = text.split('\n')
try:
lines = text.split('\n')
except AttributeError:
msg = f'expected str object, not {type(text).__qualname__!r}'
raise TypeError(msg) from None

# Get length of leading whitespace, inspired by ``os.path.commonprefix()``.
non_blank_lines = [l for l in lines if l and not l.isspace()]
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.14.0a7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Improve the import time of the :mod:`ast` module by extracting the
.. nonce: 8M-HVz
.. section: Library

Improved performance of :func:`textwrap.dedent` by an average of ~1.3x.
Improved performance of :func:`textwrap.indent` by an average of ~1.3x.
Patch by Adam Turner.

..
Expand Down
Loading