summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-03-16 22:28:07 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-03-16 22:28:07 (GMT)
commitcfec350e63ee601ce5f777d0780355b06410ccf9 (patch)
tree5427bf6d5574cf2b00c5684aee3be23ec10788b4 /Lib
parent832ebeb9d4910f15130e4e337204f18b0ed7b37b (diff)
parent4e4326829f2997624261628081110bb87c090711 (diff)
downloadcpython-cfec350e63ee601ce5f777d0780355b06410ccf9.zip
cpython-cfec350e63ee601ce5f777d0780355b06410ccf9.tar.gz
cpython-cfec350e63ee601ce5f777d0780355b06410ccf9.tar.bz2
Merge #11401 fix from 3.2.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/email/header.py2
-rw-r--r--Lib/email/test/test_email.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/Lib/email/header.py b/Lib/email/header.py
index d3118b0..8c32514 100644
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -314,7 +314,7 @@ class Header:
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
index 5adecae..721a765 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -3705,6 +3705,13 @@ A very long line that must get split to something other than at the
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