[Python-checkins] cpython (merge 3.1 -> 3.2): Merge #11401 fix from 3.1.

r.david.murray python-checkins at python.org
Wed Mar 16 23:28:24 CET 2011


http://hg.python.org/cpython/rev/2de45ced8291
changeset: 68626:2de45ced8291
branch: 3.2
parent: 68623:628a3679dc14
parent: 68625:d9c3cfd36b58
user: R David Murray <rdmurray at bitdance.com>
date: Wed Mar 16 18:27:34 2011 -0400
summary:
 Merge #11401 fix from 3.1.
files:
 Lib/email/header.py
 Lib/email/test/test_email.py
 Misc/NEWS
diff --git a/Lib/email/header.py b/Lib/email/header.py
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -314,7 +314,7 @@
 self._continuation_ws, splitchars)
 for string, charset in self._chunks:
 lines = string.splitlines()
- formatter.feed(lines[0], charset)
+ formatter.feed(lines[0] if lines else '', charset)
 for line in lines[1:]:
 formatter.newline()
 if charset.header_encoding is not None:
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -3698,6 +3698,13 @@
 h = Header('文', charset='shift_jis')
 self.assertEqual(h.encode(), '=?iso-2022-jp?b?GyRCSjgbKEI=?=')
 
+ def test_flatten_header_with_no_value(self):
+ # Issue 11401 (regression from email 4.x) Note that the space after
+ # the header doesn't reflect the input, but this is also the way
+ # email 4.x behaved. At some point it would be nice to fix that.
+ msg = email.message_from_string("EmptyHeader:")
+ self.assertEqual(str(msg), "EmptyHeader: \n\n")
+
 
 
 # Test RFC 2231 header parameters (en/de)coding
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,9 @@
 Library
 -------
 
+- Issue #11401: fix handling of headers with no value; this fixes a regression
+ relative to Python2 and the result is now the same as it was in Python2.
+
 - Issue #9298: base64 bodies weren't being folded to line lengths less than 78,
 which was a regression relative to Python2. Unlike Python2, the last line
 of the folded body now ends with a carriage return.
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /