R
Rogério Brito
Dear people,
I am a newbie in Python and I'm just writing a program to rip the HTML parts of
multipart/alternative e-mails that come with a plain text version.
For this task, I decided to leave perl aside for this task and tried to code
something in Python using what is already available in the libraries.
Unfortunately, the program that I coded exhibits a strange problem, even if I
follow what is written on the reference for Python 2.6 (I'm actually running
Debian GNU/Linux on my system, sid, updated daily).
The strange thing is that I even checked page 500 of "Python Cookbook", by Alex
Martelli, et. al. and the code in that page is actually quite similar to what I
wrote.
I'm attaching the program that I've written here, together with a fake e-mail
that triggers the bug.
The messages that I get, BTW, are the following:
# http://www.python.org/doc/2.5.2/lib/module-email.message.html
# http://docs.python.org/library/email.message.html
#
# Traceback (most recent call last):
# File "test.py", line 8, in <module>
# print msg.as_string(),
# File "/usr/lib/python2.5/email/message.py", line 131, in as_string
# g.flatten(self, unixfrom=unixfrom)
# File "/usr/lib/python2.5/email/generator.py", line 84, in flatten
# self._write(msg)
# File "/usr/lib/python2.5/email/generator.py", line 109, in _write
# self._dispatch(msg)
# File "/usr/lib/python2.5/email/generator.py", line 135, in _dispatch
# meth(msg)
# File "/usr/lib/python2.5/email/generator.py", line 175, in _handle_text
# raise TypeError('string payload expected: %s' % type(payload))
# TypeError: string payload expected: <type 'list'>
If anybody could help me with the code, I would be very grateful. Also, if you
can criticize what I wrote, I would be very happy, as I would like to improve my
Python-fu (which is minimal, unfortunately).
Thanks in advance, Rogério Brito.
I am a newbie in Python and I'm just writing a program to rip the HTML parts of
multipart/alternative e-mails that come with a plain text version.
For this task, I decided to leave perl aside for this task and tried to code
something in Python using what is already available in the libraries.
Unfortunately, the program that I coded exhibits a strange problem, even if I
follow what is written on the reference for Python 2.6 (I'm actually running
Debian GNU/Linux on my system, sid, updated daily).
The strange thing is that I even checked page 500 of "Python Cookbook", by Alex
Martelli, et. al. and the code in that page is actually quite similar to what I
wrote.
I'm attaching the program that I've written here, together with a fake e-mail
that triggers the bug.
The messages that I get, BTW, are the following:
# http://www.python.org/doc/2.5.2/lib/module-email.message.html
# http://docs.python.org/library/email.message.html
#
# Traceback (most recent call last):
# File "test.py", line 8, in <module>
# print msg.as_string(),
# File "/usr/lib/python2.5/email/message.py", line 131, in as_string
# g.flatten(self, unixfrom=unixfrom)
# File "/usr/lib/python2.5/email/generator.py", line 84, in flatten
# self._write(msg)
# File "/usr/lib/python2.5/email/generator.py", line 109, in _write
# self._dispatch(msg)
# File "/usr/lib/python2.5/email/generator.py", line 135, in _dispatch
# meth(msg)
# File "/usr/lib/python2.5/email/generator.py", line 175, in _handle_text
# raise TypeError('string payload expected: %s' % type(payload))
# TypeError: string payload expected: <type 'list'>
If anybody could help me with the code, I would be very grateful. Also, if you
can criticize what I wrote, I would be very happy, as I would like to improve my
Python-fu (which is minimal, unfortunately).
Thanks in advance, Rogério Brito.