Fix super call for python2

This commit is contained in:
Harrison Wright
2019-06-22 13:05:54 -05:00
parent 9b6400932d
commit ea4c3d0f6f

View File

@@ -18,6 +18,7 @@ import subprocess
import sys
import time
import platform
PY2 = False
try:
# python 3
from urllib.parse import urlparse
@@ -30,6 +31,7 @@ try:
from urllib.request import build_opener
except ImportError:
# python 2
PY2 = True
from urlparse import urlparse
from urllib import quote as urlquote
from urllib import urlencode
@@ -549,7 +551,11 @@ class S3HTTPRedirectHandler(HTTPRedirectHandler):
so we should remove said header on redirect.
"""
def redirect_request(self, req, fp, code, msg, headers, newurl):
request = super(S3HTTPRedirectHandler, self).redirect_request(req, fp, code, msg, headers, newurl)
if PY2:
# HTTPRedirectHandler is an old style class
request = HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, headers, newurl)
else:
request = super(S3HTTPRedirectHandler, self).redirect_request(req, fp, code, msg, headers, newurl)
del request.headers['Authorization']
return request