Is it a bug (or a feature)?

Michael Foord fuzzyman at gmail.com
Fri Aug 27 07:05:59 EDT 2004


Roman Suzi <rnd at onego.ru> wrote in message news:<mailman.2348.1093434827.5135.python-list at python.org>...
> In Python2.3.4:
> 
> >>> em = email.message_from_file(open('MAILMESSAGE'))
> >>> for i in em:
> ...   print i
> ...
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.3/email/Message.py",
> line
> 304, in __getitem__
>   File "/usr/lib/python2.3/email/Message.py",
> line
> 370, in get
> AttributeError: 'int' object has no attribute 'lower'
> 
> However items() does work:
> 
> >>> for i in em.items():
> ...   print i
> ...
> ('Date', '24 Aug 2004 16:06:01 +0400')
> ('From', 'Mail System Internal Data <MAILER-DAEMON at mydomain.ru>')
> ('Subject', "DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA")
> ('Message-ID', '<1095549161 at mydomain.ru>')
> ('X-IMAP', '1095527634 0000000005')
> ('Status', 'RO')
> 
> I can probably guess why this happens ('cause multiple fields with the
> same names are possible), but .items() is broken by this... It needn't
> be!
> 
> 
> Sincerely yours, Roman A.Suzi

It's very similar to a 'feature' in the urllib2 module. (Python 2.3.4)

>>> from urllib2 import urlopen
>>> a = urlopen('http://www.voidspace.org.uk')
>>> print a
>>> i = a.info()
>>> for entry in i: print entry
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in -toplevel-
    for entry in i: print entry
  File "D:\PYTHON23\lib\rfc822.py", line 390, in __getitem__
    return self.dict[name.lower()]
AttributeError: 'int' object has no attribute 'lower'


Regards,


Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list