diff options
| author | R David Murray <rdmurray@bitdance.com> | 2014-09-20 17:44:53 -0400 |
|---|---|---|
| committer | R David Murray <rdmurray@bitdance.com> | 2014-09-20 17:44:53 -0400 |
| commit | a2fe56bbf2d16ae2a73abeed2bfbb67ba31dcb45 (patch) | |
| tree | ec2bca440bacf2bdcae3eb1dd08b28c01e6f2a76 | |
| parent | 547e0a7260e12038aba5f298bdba936c1317530d (diff) | |
| download | cpython-a2fe56bbf2d16ae2a73abeed2bfbb67ba31dcb45.tar.gz | |
#21079: is_attachment now looks only at the value, ignoring parameters.
| -rw-r--r-- | Lib/email/message.py | 4 | ||||
| -rw-r--r-- | Lib/test/test_email/test_message.py | 3 | ||||
| -rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py index aa46debeba..124071d5e1 100644 --- a/Lib/email/message.py +++ b/Lib/email/message.py @@ -941,9 +941,7 @@ class MIMEPart(Message): @property def is_attachment(self): c_d = self.get('content-disposition') - if c_d is None: - return False - return c_d.lower() == 'attachment' + return False if c_d is None else c_d.content_disposition == 'attachment' def _find_body(self, part, preferencelist): if part.is_attachment: diff --git a/Lib/test/test_email/test_message.py b/Lib/test/test_email/test_message.py index c761c62d04..51ddf36099 100644 --- a/Lib/test/test_email/test_message.py +++ b/Lib/test/test_email/test_message.py @@ -729,7 +729,8 @@ class TestEmailMessageBase: self.assertTrue(m.is_attachment) m.replace_header('Content-Disposition', 'AtTachMent') self.assertTrue(m.is_attachment) - + m.set_param('filename', 'abc.png', 'Content-Disposition') + self.assertTrue(m.is_attachment) class TestEmailMessage(TestEmailMessageBase, TestEmailBase): @@ -32,6 +32,9 @@ Core and Builtins Library ------- +- Issue #21079: Fix email.message.EmailMessage.is_attachment to return the + correct result when the header has parameters as well as a value. + - Issue #22247: Add NNTPError to nntplib.__all__. - Issue #4180: The warnings registries are now reset when the filters |
