diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-08-03 10:08:08 -0700 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-08-04 16:21:31 +0100 |
commit | 273f4143626020321b6cf15f94ff0a5ec71d642d (patch) | |
tree | f45df49e1b2f0c99c949f30c4cfab1cc7d465b6c | |
parent | 6221824388b0e43c6e2980934f14e4374628995d (diff) |
db: encode Header objects to str
In python 3 with the use of Policy objects (other than the Compat32
object which maintains the previous (python 2.x and <=3.2) API) change
the way headers work, and the old Header object is no longer used. This
is rather convenient in that python now implements many of the rules
required for sepcial header types, but it changes the API. This fixes
that by encoding the Header objects to strings.
Fixes #1289
-rw-r--r-- | alot/db/attachment.py | 2 | ||||
-rw-r--r-- | alot/db/utils.py | 2 | ||||
-rw-r--r-- | tests/db/envelope_test.py | 2 |
3 files changed, 2 insertions, 4 deletions
diff --git a/alot/db/attachment.py b/alot/db/attachment.py index ec0feaeb..2868ed66 100644 --- a/alot/db/attachment.py +++ b/alot/db/attachment.py @@ -89,5 +89,5 @@ class Attachment(object): part['Content-Disposition'] = Header( self.part['Content-Disposition'], maxlinelen=78, - header_name='Content-Disposition') + header_name='Content-Disposition').encode() return part diff --git a/alot/db/utils.py b/alot/db/utils.py index e750bfbb..33330f72 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -531,7 +531,7 @@ def encode_header(key, value): value = Header(', '.join(encodedentries)) else: value = Header(value) - return value + return value.encode() def is_subdir_of(subpath, superpath): diff --git a/tests/db/envelope_test.py b/tests/db/envelope_test.py index de01eaf7..f14b8594 100644 --- a/tests/db/envelope_test.py +++ b/tests/db/envelope_test.py @@ -72,7 +72,6 @@ class TestEnvelope(unittest.TestCase): actual = email.parser.Parser().parsestr(raw) self.assertEmailEqual(mail, actual) - @unittest.expectedFailure @mock.patch('alot.db.envelope.settings', SETTINGS) def test_construct_mail_simple(self): """Very simple envelope with a To, From, Subject, and body.""" @@ -85,7 +84,6 @@ class TestEnvelope(unittest.TestCase): bodytext='Test') self._test_mail(e) - @unittest.expectedFailure @mock.patch('alot.db.envelope.settings', SETTINGS) def test_construct_mail_with_attachment(self): """Very simple envelope with a To, From, Subject, body and attachment. |