New submission from Andres Riancho <andres.rian...@gmail.com>: Buggy Code:
""" def http_error_302(self, req, fp, code, msg, headers): # Some servers (incorrectly) return multiple Location headers # (so probably same goes for URI). Use first header. if 'location' in headers: newurl = headers.getheaders('location')[0] elif 'uri' in headers: newurl = headers.getheaders('uri')[0] else: return """ The getheaders method is not be defined for the headers parameter, which is a dict object. This seems to be a mistake with the HTTPResponse. getheaders function that's defined in httplib.py Fixed Code: """ def http_error_302(self, req, fp, code, msg, headers): # Some servers (incorrectly) return multiple Location headers # (so probably same goes for URI). Use first header. if 'location' in headers: newurl = headers.get('location') elif 'uri' in headers: newurl = headers.get('uri') else: return """ ---------- components: Extension Modules messages: 129026 nosy: Andres.Riancho priority: normal severity: normal status: open title: urllib2 http_error_302 calls undefined "getheaders" method type: crash versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11280> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com