Skip to content

Commit

Permalink
Workaround a Python 3.2.0 bug in handling emails with empty headers.
Browse files Browse the repository at this point in the history
Fixes #14.
  • Loading branch information
rpatterson committed Mar 20, 2012
1 parent fb2a013 commit 23e334b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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)
----------------

Expand Down
2 changes: 2 additions & 0 deletions pyramid_mailer/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pyramid_mailer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23e334b

Please sign in to comment.