Bug in email package?
Roman Suzi
rnd at onego.ru
Sun Feb 20 16:23:16 EST 2005
I was playing with email package and discovrered this strange kind of
behaviour:
>>> import email.Message
>>> m = email.Message.Message()
>>> m['a'] = '123'
>>> print m
>From nobody Mon Feb 21 00:12:27 2005
a: 123
>>> for i in m: print i
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.3/email/Message.py", line 304, in __getitem__
return self.get(name)
File "/usr/local/lib/python2.3/email/Message.py", line 370, in get
name = name.lower()
AttributeError: 'int' object has no attribute 'lower'
I think that if any object (from standard library at least) doesn't support
iteration, it should clearly state so.
My guess is that 'for' causes the use of 'm[0]', which is (rightfully) an
error...
Can this behaviour of email be considered a bug?
Is there a good case to iterate over something useful in a message?
P.S. rfc822 has the same behaviour, at least on Python 2.3
Sincerely yours, Roman Suzi
--
rnd at onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
More information about the Python-list
mailing list