We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 311ac87 commit f2050aeCopy full SHA for f2050ae
Lib/textwrap.py
@@ -429,16 +429,13 @@ def dedent(text):
429
if not text:
430
return text
431
432
- # If the input is entirely whitespace, return normalized lines.
433
- if text.isspace():
434
- return '\n' * text.count('\n')
435
-
436
lines = text.split('\n')
437
438
# Get length of leading whitespace, inspired by ``os.path.commonprefix()``.
439
non_blank_lines = [l for l in lines if l and not l.isspace()]
440
- l1 = min(non_blank_lines)
441
- l2 = max(non_blank_lines)
+ l1 = min(non_blank_lines, default='')
+ l2 = max(non_blank_lines, default='')
+ margin = 0
442
for margin, c in enumerate(l1):
443
if c != l2[margin] or c not in ' \t':
444
break
0 commit comments