summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2001-03-23 17:30:26 +0000
committerAndrew M. Kuchling <amk@amk.ca>2001-03-23 17:30:26 +0000
commit87ce7581e48a3d18da7de2ccf1a32942e56453fd (patch)
treef3eee84edd934369c656a67d7973c513519e285b /Lib
parent3ea82b16bf8a6260c7f768f4a68627eb77305e91 (diff)
downloadcpython-87ce7581e48a3d18da7de2ccf1a32942e56453fd.tar.gz
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)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/util.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 010db9a3b0..01abd346d5 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -446,10 +446,11 @@ byte_compile(files, optimize=%s, force=%s,
def rfc822_escape (header):
"""Return a version of the string escaped for inclusion in an
- RFC-822 header, by adding a space after each newline.
+ RFC-822 header, by ensuring there are 8 spaces space after each newline.
"""
- header = string.rstrip(header)
- header = string.replace(header, '\n', '\n ')
+ lines = string.split(header, '\n')
+ lines = map(string.strip, lines)
+ header = string.join(lines, '\n' + 8*' ')
return header