diff cagou/core/patches.py @ 312:772c170b47a9

Python3 port: /!\ Cagou now runs with Python 3.6+ Port has been done in the same way as for backend (check backend commit b2d067339de3 message for details).
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:14:22 +0200
parents b0461363bc65
children 4d660b252487
line wrap: on
line diff
--- a/cagou/core/patches.py	Mon Aug 05 11:21:54 2019 +0200
+++ b/cagou/core/patches.py	Tue Aug 13 19:14:22 2019 +0200
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import urllib2
+import urllib.request, urllib.error, urllib.parse
 import ssl
 
 
@@ -27,14 +27,14 @@
     ctx_no_verify.check_hostname = False
     ctx_no_verify.verify_mode = ssl.CERT_NONE
 
-    class HTTPSHandler(urllib2.HTTPSHandler):
+    class HTTPSHandler(urllib.request.HTTPSHandler):
         no_certificate_check = False
 
         def __init__(self, *args, **kwargs):
-            urllib2._HTTPSHandler_ori.__init__(self, *args, **kwargs)
+            urllib.request._HTTPSHandler_ori.__init__(self, *args, **kwargs)
             if self.no_certificate_check:
                 self._context = ctx_no_verify
 
-    urllib2._HTTPSHandler_ori = urllib2.HTTPSHandler
-    urllib2.HTTPSHandler = HTTPSHandler
-    urllib2.HTTPSHandler.no_certificate_check = True
+    urllib.request._HTTPSHandler_ori = urllib.request.HTTPSHandler
+    urllib.request.HTTPSHandler = HTTPSHandler
+    urllib.request.HTTPSHandler.no_certificate_check = True