It is not clear how to pass initial list of messages to
MIMEMultipart.
From doc it seems that _subparts should be a single
list-like object, from source it seems that it expects
seperate parameters - neither work...
My suggested patch implemets the single parameter way
(after applying it, the second try in the example below
does work).
((to apply the patch, use :
cp MIMEMultipart.py MIMEMultipart_orig.py
patch -i MIMEMultipart_2.3.3.diff -o MIMEMultipart.py
MIMEMultipart_orig.py
))
example:
>>> msgs = [MIMEText('a'),MIMEText('b')]
>>> MIMEMultipart('mixed',None,msgs[0],msgs[1])
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/email/MIMEMultipart.py",
line 35, in __init__
self.attach(*list(_subparts))
TypeError: attach() takes exactly 2 arguments (3 given)
>>> MIMEMultipart('mixed',None,msgs).as_string()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/email/Message.py", line 130,
in as_string
g.flatten(self, unixfrom=unixfrom)
File "/usr/lib/python2.3/email/Generator.py", line
102, in flatten
self._write(msg)
File "/usr/lib/python2.3/email/Generator.py", line
130, in _write
self._dispatch(msg)
File "/usr/lib/python2.3/email/Generator.py", line
156, in _dispatch
meth(msg)
File "/usr/lib/python2.3/email/Generator.py", line
230, in _handle_multipart
g.flatten(part, unixfrom=False)
File "/usr/lib/python2.3/email/Generator.py", line
102, in flatten
self._write(msg)
File "/usr/lib/python2.3/email/Generator.py", line
130, in _write
self._dispatch(msg)
File "/usr/lib/python2.3/email/Generator.py", line
147, in _dispatch
main = msg.get_content_maintype()
AttributeError: 'list' object has no attribute
'get_content_maintype'
>>>
|