[ python-Bugs-1030125 ] rfc822 __iter__ problem

SourceForge.net noreply at sourceforge.net
Tue Sep 21 07:12:13 CEST 2004


Bugs item #1030125, was opened at 2004-09-17 17:10
Message generated for change (Comment added) made by rhettinger
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: Raymond Hettinger (rhettinger)
Date: 2004-09-21 00: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