diff --git a/CHANGES.txt b/CHANGES.txt index be69ac9..ae1d9a4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +0.7 (Unreleased) +---------------- + +- Workaround a Python 3.2.0 bug in handling emails with empty + headers. + 0.6 (2012-03-20) ---------------- diff --git a/pyramid_mailer/response.py b/pyramid_mailer/response.py index c29b9d9..234de24 100644 --- a/pyramid_mailer/response.py +++ b/pyramid_mailer/response.py @@ -343,6 +343,8 @@ def to_message(mail): if k.lower() in encoding.ADDR_HEADERS: if is_nonstr_iter(value): # not a string value = ", ".join(value) + if value == '': + continue out[k] = value out.extract_payload(mail) diff --git a/pyramid_mailer/tests.py b/pyramid_mailer/tests.py index 2c56241..650a14a 100644 --- a/pyramid_mailer/tests.py +++ b/pyramid_mailer/tests.py @@ -976,6 +976,12 @@ def test_no_ctype_no_parts(self): result = self._callFUT(mail) self.assertEqual(result.__class__, MIMEPart) + def test_empty_header(self): + mail = self._makeBase() + mail['To'] = '' + result = self._callFUT(mail) + self.assertFalse('To' in result) + class TestMIMEPart(unittest.TestCase): def _makeOne(self, type, **params): from pyramid_mailer.response import MIMEPart