[New-bugs-announce] [issue1822] email.mime.multipart.MIMEMultipart.is_multipart() returns false before items have been added.

Jonathan Share report at bugs.python.org
Mon Jan 14 11:54:57 CET 2008


New submission from Jonathan Share:

Steps to reproduce
==================
>>> from email.mime.multipart import MIMEMultipart
>>> foo = MIMEMultipart()
>>> foo.is_multipart()
False

Expected Result
===============
True should be returned from MIMEMultipart.is_multipart()

Notes
=====
Looking at the implementation of is_multipart() in email.Message it 
would appear that if self._payload was initialised to an empty list in 
the constructor of MIMEMultipart when _subparts is None, this would be 
a sufficient fix for this issue.

However, from an outsider looking into this code for the first time, 
this doesn't look like the best architecture, shouldn't the issue of 
whether a message has multiple parts, and logic specific to this be 
handled through inheritance. With the current implementation the 
superclass makes assumptions about how a subclass is implemented, this 
just feels wrong. Have I missed something, is there a good reason for 
things being as they are today?

Feel free to take the discussion to the python-dev list, I have just 
subscribed, and I am interested in fixing this issue myself in the next 
bug day if someone can answer my questions above.

----------
components: Library (Lib)
messages: 59895
nosy: Sharebear
severity: normal
status: open
title: email.mime.multipart.MIMEMultipart.is_multipart() returns false before items have been added.
type: behavior
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1822>
__________________________________


More information about the New-bugs-announce mailing list