cpython: a3df1c24d586 (original) (raw)

Mercurial > cpython

changeset 92494:a3df1c24d586 3.4

#21091: make is_attachment a method. Since EmailMessage is a provisional API we can fix API bugs in a maintenance release, but I used a trick suggested by Serhiy to maintain backward compatibility with 3.4.0/1. [#21091]

R David Murray rdmurray@bitdance.com
date Sat, 20 Sep 2014 18:05:28 -0400
parents 0044ed0af96f
children f7aff40609e7 7af0315bdfe0
files Doc/library/email.contentmanager.rst Lib/email/message.py Lib/test/test_email/test_message.py Misc/NEWS
diffstat 4 files changed, 43 insertions(+), 10 deletions(-)[+] [-] Doc/library/email.contentmanager.rst 8 Lib/email/message.py 20 Lib/test/test_email/test_message.py 20 Misc/NEWS 5

line wrap: on

line diff

--- a/Doc/library/email.contentmanager.rst +++ b/Doc/library/email.contentmanager.rst @@ -70,11 +70,15 @@ this module. the following methods:

+ .. method:: get_body(preferencelist=('related', 'html', 'plain'))

--- a/Lib/email/message.py +++ b/Lib/email/message.py @@ -9,6 +9,7 @@ import re import uu import quopri +import warnings from io import BytesIO, StringIO

Intrapackage imports

@@ -929,6 +930,17 @@ class Message: # I.e. def walk(self): ... from email.iterators import walk +# XXX Support for temporary deprecation hack for is_attachment property. +class _IsAttachment:

class MIMEPart(Message): @@ -941,10 +953,12 @@ class MIMEPart(Message): @property def is_attachment(self): c_d = self.get('content-disposition')

def _find_body(self, part, preferencelist):

@@ -1037,7 +1051,7 @@ class MIMEPart(Message): for part in parts: maintype, subtype = part.get_content_type().split('/') if ((maintype, subtype) in self._body_types and

--- a/Lib/test/test_email/test_message.py +++ b/Lib/test/test_email/test_message.py @@ -722,15 +722,25 @@ class TestEmailMessageBase: def test_is_attachment(self): m = self._make_message()

class TestEmailMessage(TestEmailMessageBase, TestEmailBase):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -32,6 +32,11 @@ Core and Builtins Library ------- +- Issue #21091: Fix API bug: email.message.EmailMessage.is_attachment is now