diff tests/tinyproxy.py @ 29566:075146e85bb6

py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import The BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer has been merged into http.server in python 3. All of them has been merged as util.httpserver to use in both python 2 and 3. This patch adds a regex to check-code to warn against the use of BaseHTTPServer. Moreover this patch also includes updates to lower part of test-check-py3-compat.t which used to remain unchanged.
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 13 Jul 2016 23:38:29 +0530
parents 143d21a7343e
children d8d698bcdcd6
line wrap: on
line diff
--- a/tests/tinyproxy.py	Fri Jul 15 23:00:31 2016 +0530
+++ b/tests/tinyproxy.py	Wed Jul 13 23:38:29 2016 +0530
@@ -14,7 +14,6 @@
 
 __version__ = "0.2.1"
 
-import BaseHTTPServer
 import optparse
 import os
 import select
@@ -23,11 +22,12 @@
 
 from mercurial import util
 
+httpserver = util.httpserver
 urlparse = util.urlparse
 socketserver = util.socketserver
 
-class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
-    __base = BaseHTTPServer.BaseHTTPRequestHandler
+class ProxyHandler (httpserver.basehttprequesthandler):
+    __base = httpserver.basehttprequesthandler
     __base_handle = __base.handle
 
     server_version = "TinyHTTPProxy/" + __version__
@@ -137,9 +137,9 @@
     do_DELETE = do_GET
 
 class ThreadingHTTPServer (socketserver.ThreadingMixIn,
-                           BaseHTTPServer.HTTPServer):
+                           httpserver.httpserver):
     def __init__(self, *args, **kwargs):
-        BaseHTTPServer.HTTPServer.__init__(self, *args, **kwargs)
+        httpserver.httpserver.__init__(self, *args, **kwargs)
         a = open("proxy.pid", "w")
         a.write(str(os.getpid()) + "\n")
         a.close()