classification
Title: urllib2 .getheaders attribute error
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: calvin, fdrake, jjlee
Priority: normal Keywords: patch

Created on 2005-02-07 00:18 by calvin, last changed 2005-03-24 21:15 by fdrake. This issue is now closed.

Files
File name Uploaded Description Edit
urllib_headers.diff calvin, 2005-02-07 00:18
Messages (4)
msg47712 - (view) Author: Bastian Kleineidam (calvin) Date: 2005-02-07 00:18
The headers arguments to all methods are dictionaries,
however the http_error_302 method calls
headers.getheaders() which results in an attribute error.
The attached patch against current CVS fixes this by
using headers.get() instead of .getheaders().
msg47713 - (view) Author: John J Lee (jjlee) Date: 2005-02-20 01:45
Logged In: YES 
user_id=261020

I can't see where your AttributeError is coming from.

Thankyou very much for the bug report, but *please* supply
some means of reproducing the problem!

> The headers arguments to all methods are dictionaries,

They are in fact always httplib.HTTPMessage instances, as
far as I can see.  That class inherits a .getheaders()
method from rfc822.Message.  (And FWIW, so far as I can see,
the type of the "hdrs" arguments to the .http_error_*()
handler methods are not documented.)

Moreover, .getheaders() and .get() don't mean the same thing
in general: HTTPMessage.getheaders(name)[0] preserves header
ordering information, where eg. dict.get(name) does not.  
msg47714 - (view) Author: Bastian Kleineidam (calvin) Date: 2005-03-08 10:33
Logged In: YES 
user_id=9205

Hm, I _could_ reproduce this, but not anymore. I should have
saved the test program :/. Well, you can close this bug. If
I encounter this problem again I will post a little test script.
msg47715 - (view) Author: Fred L. Drake, Jr. (fdrake) (Python committer) Date: 2005-03-24 21:15
Logged In: YES 
user_id=3066

Closing based on follow-up comments.
History
Date User Action Args
2005-02-07 00:18:37calvincreate