mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-05 16:18:02 +01:00
Fix super call for python2
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user