More refactoring like the last couple of commits

This commit is contained in:
Miroslav Stampar
2019-01-22 02:08:02 +01:00
parent fd705c3dff
commit 7074365f8e
22 changed files with 144 additions and 137 deletions

View File

@@ -141,8 +141,8 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
try:
result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
except urllib2.HTTPError, e:
result = e
except urllib2.HTTPError as ex:
result = ex
# Dirty hack for http://bugs.python.org/issue15701
try:
@@ -154,7 +154,7 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
if not hasattr(result, "read"):
def _(self, length=None):
return e.msg
return ex.msg
result.read = types.MethodType(_, result)
if not getattr(result, "url", None):