Author mwatkins
Recipients mwatkins
Date 2009-01-25.15:24:31
SpamBayes Score 3.75308e-10
Marked as misclassified No
Message-id <1232897073.53.0.7443757693.issue5053@psf.upfronthosting.co.za>
In-reply-to
Content
HTTPMessage.getallmatchingheaders() stopped working sometime after 
Python 3.0 release. In a recent (1 day ago) svn update the 
implementation says the method was copied from rfc822.message; the 
Python 3.x implementation is broken (iterates through self.keys instead 
of header values). I've not looked back to see where the change was 
introduced but I do know that it broke post 3.0 release.

But more importantly than the flaw in this method, the functionality is 
duplicated elsewhere in Python 3.x.

I propose either deprecating getallmatchingheaders() or if it is to be 
kept for compatibility, the fix can be simply replacing the method body 
with:

self.get_all(name)

The docstring for get_all (defined in email.message) affirms that its 
output is indeed compatible with that which was intended for 
getallmatchingheaders().

get_all(self, name, failobj=None) method of client.HTTPMessage instance
    Return a list of all the values for the named field.
    
    These will be sorted in the order they appeared in the original
    message, and may contain duplicates.  Any fields deleted and
    re-inserted are always appended to the header list.
    
    If no such fields exist, failobj is returned (defaults to None).

I've tested the use of get_all against one web server (QP) which runs on 
both Python 2.x and 3.x.

As a result of the broken getallmatchingheaders() the QP web server now 
uses for the same purpose as getallmatchingheaders() instead: 
get_all(name) (defined in email.message.Message in Py3k and 
getheaders(name) (defined in rfc822.Message).

See also issues on documentation and changed API in #4773, #3428
History
Date User Action Args
2009-01-25 15:24:33mwatkinssetrecipients: + mwatkins
2009-01-25 15:24:33mwatkinssetmessageid: <1232897073.53.0.7443757693.issue5053@psf.upfronthosting.co.za>
2009-01-25 15:24:32mwatkinslinkissue5053 messages
2009-01-25 15:24:31mwatkinscreate