Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88b0884

Browse files
committed
Change rfc822_escape() to ensure there's a consistent amount of whitespace
after each newline, instead of just blindly inserting a space at the start of each line. (Improvement suggested by Thomas Wouters)
1 parent aa90adc commit 88b0884

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Lib/distutils/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,11 @@ def byte_compile (py_files,
446446

447447
def rfc822_escape (header):
448448
"""Return a version of the string escaped for inclusion in an
449-
RFC-822 header, by adding a space after each newline.
449+
RFC-822 header, by ensuring there are 8 spaces space after each newline.
450450
"""
451-
header = string.rstrip(header)
452-
header = string.replace(header, '\n', '\n ')
451+
lines = string.split(header, '\n')
452+
lines = map(string.strip, lines)
453+
header = string.join(lines, '\n' + 8*' ')
453454
return header
454455

455456

0 commit comments

Comments
 (0)