[ python-Bugs-1030125 ] rfc822 __iter__ problem
SourceForge.net
noreply at sourceforge.net
Wed Sep 22 18:35:46 CEST 2004
Bugs item #1030125, was opened at 2004-09-17 18:10
Message generated for change (Comment added) made by bwarsaw
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1030125&group_id=5470
Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Foord (mjfoord)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: rfc822 __iter__ problem
Initial Comment:
>>> from urllib2 import urlopen
>>> a = urlopen('http://www.voidspace.org.uk')
>>> 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'
Iterating over an rfc822 message (above done from
urllib2) causes an exception. Could be fixed by returning
an iter(self.dict) from the __iter__ method.
This bug looks similar to bug 1017329.
----------------------------------------------------------------------
>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2004-09-22 12:35
Message:
Logged In: YES
user_id=12800
It doesn't seem right to me to inherit from UserDict since a
Message is definitely /not/ a dictionary. E.g. it may have
multiple occurances of the same header.
I'm fine with adding an __iter__ if you want because even
though rfc822 is slated for deprecation, unfortunately there
are still parts of the stdlib that haven't been rewritten to
use the email package.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2004-09-21 02:03
Message:
Logged In: YES
user_id=80475
See attached patch.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2004-09-21 01:12
Message:
Logged In: YES
user_id=80475
This seems like a reasonable feature request. Though I
don't know if it makes sense to improve a module that is
slated for deprecation per PEP 4.
If accepted, I would subclass from UserDict.DictMixin to
complete the dictionary iterface including __iter__.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1030125&group_id=5470
More information about the Python-bugs-list
mailing list