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 <MA***********@mydomain.ru>')
('Subject', "DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA")
('Message-ID', '<10********@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
--
- Petrozavodsk - Karelia - Russia - mailto:rn*@onego.ru - 7 1750
"Roman Suzi" <rn*@onego.ru> wrote in message
news:ma**************************************@pyth on.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 <MA***********@mydomain.ru>') ('Subject', "DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA") ('Message-ID', '<10********@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 -- - Petrozavodsk - Karelia - Russia - mailto:rn*@onego.ru -
Looks like a bug to me. Message.__getitem__() makes a call to
Message.get(), assuming that the argument passed in is a key name (such as
'Date', 'From', etc. from your example). __getitem__ should first check to
see if the input argument (named 'name', further indication that this method
was written to expect only strings) is an integer or slice, and if so, just
return self._headers[name].
-- Paul
Looking further at Message.py, __delitem__ has this same problem. When
fixing this, should probably also add an __iter__ method, that would return
iter(self._headers).
-- Paul
This looks like a bug. Please open a bug on SF, with the example code.
This looks like a bug. Please open a bug on SF, with the example code.
"Anthony Baxter" <an***********@gmail.com> wrote in message
news:ma**************************************@pyth on.org... This looks like a bug. Please open a bug on SF, with the example code.
Do you mean me or the OP?
-- Paul
"Anthony Baxter" <an***********@gmail.com> wrote in message
news:ma**************************************@pyth on.org... This looks like a bug. Please open a bug on SF, with the example code.
I just opened this bug, it is number 1017329.
-- Paul
Roman Suzi <rn*@onego.ru> wrote in message news:<ma**************************************@pyt hon.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 <MA***********@mydomain.ru>') ('Subject', "DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA") ('Message-ID', '<10********@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/atlantib...thonutils.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dayzman |
last post by:
Hi,
I've read somewhere that feature-based analysis can be used to extract
the semantic structure of HTML documents. By semantic structure, they
mean the model of the rendered view a reader...
|
by: scsharma |
last post by:
Hi,
I am using .Net on Windows XP Professional. I am facing a unique problem
with visual studio where intellisense feature is getting turned off. If i
close IDE and reopen my solution the...
|
by: christopher diggins |
last post by:
A feature that I find signficantly missing in C# is the ability to write
functions in interfaces that can call other functions of the interface.
Given an interface ISomeInteface the only way we can...
|
by: Kamen Yotov |
last post by:
hi all,
i first posted this on
http://msdn.microsoft.com/vcsharp/team/language/ask/default.aspx
(ask a c# language designer) a couple of days ago, but no response so far...
therefore, i am...
|
by: Russell Mangel |
last post by:
I was thinking about what IDE feature I would want the most in the next
version of VC++?
I would definately ask for the C# feature: #region / #endregion.
In my opinion this feature was a...
| |
by: Raymond Hettinger |
last post by:
Proposal
--------
I am gathering data to evaluate a request for an alternate version of
itertools.izip() with a None fill-in feature like that for the built-in
map() function:
>>> map(None,...
|
by: Raymond Hettinger |
last post by:
I am evaluating a request for an alternate version of itertools.izip()
that has a None fill-in feature like the built-in map function:
>>> map(None, 'abc', '12345') # demonstrate map's None...
|
by: =?Utf-8?B?RGFyYSBQ?= |
last post by:
Would like to know from the crowd that why do we require a Partial Class. By
having such feature aren't we going out of the scope of Entity Concept.
Help me to understand in what context this...
|
by: Luke R |
last post by:
One thing i used to use alot in vb6 was that tiny little button in the
bottom left of the code window which allowed you to view either the whole
code file, or just the function/sub you are currenly...
|
by: Conrad Lender |
last post by:
In a recent thread in this group, I said that in some cases object
detection and feature tests weren't sufficient in the development of
cross-browser applications, and that there were situations...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |