Package: reportbug
Version: 3.12
Severity: minor
Tags: patch
Hi,
I am using your urlutils.py stuff in LinkChecker and noticed that
redirections are broken when running under Python 2.4:
[...]
File "/usr/lib/python2.4/urllib2.py", line 364, in open
response = meth(req, response)
File "/usr/lib/python2.4/urllib2.py", line 471, in http_response
response = self.parent.error(
File "/usr/lib/python2.4/urllib2.py", line 396, in error
result = self._call_chain(*args)
File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
result = func(*args)
File "/usr/lib/python2.4/urllib2.py", line 523, in http_error_302
newurl = headers.getheaders('location')[0]
AttributeError: 'dict' object has no attribute 'getheaders'
An URL that fails is http://de.finance.yahoo.com/robots.txt
The fix is to always use a HTTPMessage object for headers in handler
methods. Attached is a patch which should also work on Python 2.3.
Regards,
Bastian
-- Package-specific info:
** Environment settings:
EDITOR="fte"
DEBEMAIL="[EMAIL PROTECTED]"
** /home/calvin/.reportbugrc:
reportbug_version "3.11"
mode advanced
ui text
realname "Bastian Kleineidam"
email "[EMAIL PROTECTED]"
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.11-treasure3
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)
Versions of packages reportbug depends on:
ii python2.3 2.3.5-3 An interactive high-level object-o
-- no debconf information
--- /usr/share/reportbug/urlutils.py 2005-05-11 00:25:32.000000000 +0200
+++ /home/calvin/urlutils.py 2005-05-18 19:45:37.368809628 +0200
@@ -53,7 +53,7 @@
import gzip
fp = gzip.GzipFile('', 'rb', 9, StringIO(content))
# remove content-encoding header
- headers = {}
+ headers = httplib.HTTPMessage(StringIO.StringIO(""))
ceheader = re.compile(r"(?i)content-encoding:")
for h in page.info().keys():
if not ceheader.match(h):