class MyURLopener(urllib.URLopener):
# Error 301 -- relocated (permanently)
def http_error_301(self, url, fp, errcode, errmsg, headers, data=None):
- if headers.has_key('location'):
+ if 'location' in headers:
newurl = headers['location']
- elif headers.has_key('uri'):
+ elif 'uri' in headers:
newurl = headers['uri']
else:
newurl = "Nowhere"
def http_error_default(self, url, fp, errcode, errmsg, headers):
if fp:
- void = fp.read()
+ fp.read()
fp.close()
raise IOError(('http error', errcode, errmsg, headers))