mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-06 00:28:01 +01:00
Fix super call for python2
This commit is contained in:
@@ -18,6 +18,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import platform
|
import platform
|
||||||
|
PY2 = False
|
||||||
try:
|
try:
|
||||||
# python 3
|
# python 3
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
@@ -30,6 +31,7 @@ try:
|
|||||||
from urllib.request import build_opener
|
from urllib.request import build_opener
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# python 2
|
# python 2
|
||||||
|
PY2 = True
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
from urllib import quote as urlquote
|
from urllib import quote as urlquote
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
@@ -549,7 +551,11 @@ class S3HTTPRedirectHandler(HTTPRedirectHandler):
|
|||||||
so we should remove said header on redirect.
|
so we should remove said header on redirect.
|
||||||
"""
|
"""
|
||||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
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']
|
del request.headers['Authorization']
|
||||||
return request
|
return request
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user