policy = default
Message.__init__(self, policy)
-- @property
def is_attachment(self):
c_d = self.get('content-disposition')
- result = False if c_d is None else c_d.content_disposition == 'attachment'
- # XXX transitional hack to raise deprecation if not called.
- return _IsAttachment(result)
+ 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':
def test_is_attachment(self):
m = self._make_message()
- self.assertFalse(m.is_attachment)
+ self.assertFalse(m.is_attachment())
- with self.assertWarns(DeprecationWarning):
- self.assertFalse(m.is_attachment)
m['Content-Disposition'] = 'inline'
- self.assertFalse(m.is_attachment)
+ self.assertFalse(m.is_attachment())
- with self.assertWarns(DeprecationWarning):
- self.assertFalse(m.is_attachment)
m.replace_header('Content-Disposition', 'attachment')
- self.assertTrue(m.is_attachment)
+ self.assertTrue(m.is_attachment())
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(m.is_attachment)
m.replace_header('Content-Disposition', 'AtTachMent')
- self.assertTrue(m.is_attachment)
+ self.assertTrue(m.is_attachment())
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(m.is_attachment)
m.set_param('filename', 'abc.png', 'Content-Disposition')
- self.assertTrue(m.is_attachment)
+ self.assertTrue(m.is_attachment())
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(m.is_attachment)
class TestEmailMessage(TestEmailMessageBase, TestEmailBase):
Library
-------
- a method. Since EmailMessage is provisional, we can change the API in a
- maintenance release, but we use a trick to remain backward compatible with
- 3.4.0/1.
+ - Issue #21091: Fix API bug: email.message.EmailMessage.is_attachment is now
++ a method.
+
- Issue #21079: Fix email.message.EmailMessage.is_attachment to return the
correct result when the header has parameters as well as a value.