Mercurial > hg
diff mercurial/hgweb/server.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 | 121d11814c62 |
children | ebc03e64548a |
line wrap: on
line diff
--- a/mercurial/hgweb/server.py Fri Jul 15 23:00:31 2016 +0530 +++ b/mercurial/hgweb/server.py Wed Jul 13 23:38:29 2016 +0530 @@ -8,7 +8,6 @@ from __future__ import absolute_import -import BaseHTTPServer import errno import os import socket @@ -22,6 +21,7 @@ util, ) +httpservermod = util.httpserver socketserver = util.socketserver urlerr = util.urlerr urlreq = util.urlreq @@ -53,7 +53,7 @@ for msg in seq: self.handler.log_error("HG error: %s", msg) -class _httprequesthandler(BaseHTTPServer.BaseHTTPRequestHandler): +class _httprequesthandler(httpservermod.basehttprequesthandler): url_scheme = 'http' @@ -64,7 +64,7 @@ def __init__(self, *args, **kargs): self.protocol_version = 'HTTP/1.1' - BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kargs) + httpservermod.basehttprequesthandler.__init__(self, *args, **kargs) def _log_any(self, fp, format, *args): fp.write("%s - - [%s] %s\n" % (self.client_address[0], @@ -263,14 +263,14 @@ return open(opt, 'a') return default -class MercurialHTTPServer(object, _mixin, BaseHTTPServer.HTTPServer): +class MercurialHTTPServer(object, _mixin, httpservermod.httpserver): # SO_REUSEADDR has broken semantics on windows if os.name == 'nt': allow_reuse_address = 0 def __init__(self, ui, app, addr, handler, **kwargs): - BaseHTTPServer.HTTPServer.__init__(self, addr, handler, **kwargs) + httpservermod.httpserver.__init__(self, addr, handler, **kwargs) self.daemon_threads = True self.application = app