diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-09-20 22:16:39 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-09-20 22:16:39 (GMT) |
commit | 7c4093ca95b9aebd11dad069bcdb20f9b0ce902d (patch) | |
tree | d3923c715776e92db6610865b6dda9ec554118ef /Lib | |
parent | 1de0ac05f3467faad2e0a0d6d08f86c06bf43b1b (diff) | |
parent | 8a97896a765e4b1ef8753b4a410a8f3e981cb9b8 (diff) | |
download | cpython-7c4093ca95b9aebd11dad069bcdb20f9b0ce902d.zip cpython-7c4093ca95b9aebd11dad069bcdb20f9b0ce902d.tar.gz cpython-7c4093ca95b9aebd11dad069bcdb20f9b0ce902d.tar.bz2 |
Merge: #21091: make is_attachment a method.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/email/message.py | 6 | ||||
-rw-r--r-- | Lib/test/test_email/test_message.py | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py index 124071d..727cd1e 100644 --- a/Lib/email/message.py +++ b/Lib/email/message.py @@ -9,6 +9,7 @@ __all__ = ['Message'] import re import uu import quopri +import warnings from io import BytesIO, StringIO # Intrapackage imports @@ -938,13 +939,12 @@ class MIMEPart(Message): policy = default Message.__init__(self, policy) - @property def is_attachment(self): c_d = self.get('content-disposition') return False if c_d is None else c_d.content_disposition == 'attachment' def _find_body(self, part, preferencelist): - if part.is_attachment: + if part.is_attachment(): return maintype, subtype = part.get_content_type().split('/') if maintype == 'text': @@ -1037,7 +1037,7 @@ class MIMEPart(Message): for part in parts: maintype, subtype = part.get_content_type().split('/') if ((maintype, subtype) in self._body_types and - not part.is_attachment and subtype not in seen): + not part.is_attachment() and subtype not in seen): seen.append(subtype) continue yield part diff --git a/Lib/test/test_email/test_message.py b/Lib/test/test_email/test_message.py index 51ddf36..d78049e 100644 --- a/Lib/test/test_email/test_message.py +++ b/Lib/test/test_email/test_message.py @@ -722,15 +722,15 @@ class TestEmailMessageBase: def test_is_attachment(self): m = self._make_message() - self.assertFalse(m.is_attachment) + self.assertFalse(m.is_attachment()) m['Content-Disposition'] = 'inline' - self.assertFalse(m.is_attachment) + self.assertFalse(m.is_attachment()) m.replace_header('Content-Disposition', 'attachment') - self.assertTrue(m.is_attachment) + self.assertTrue(m.is_attachment()) m.replace_header('Content-Disposition', 'AtTachMent') - self.assertTrue(m.is_attachment) + self.assertTrue(m.is_attachment()) m.set_param('filename', 'abc.png', 'Content-Disposition') - self.assertTrue(m.is_attachment) + self.assertTrue(m.is_attachment()) class TestEmailMessage(TestEmailMessageBase, TestEmailBase): |