Mercurial > hg
comparison mercurial/hgweb/common.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 | 7f0498bd284e |
children | bb77654dc7ae |
comparison
equal
deleted
inserted
replaced
29565:143d21a7343e | 29566:075146e85bb6 |
---|---|
6 # This software may be used and distributed according to the terms of the | 6 # This software may be used and distributed according to the terms of the |
7 # GNU General Public License version 2 or any later version. | 7 # GNU General Public License version 2 or any later version. |
8 | 8 |
9 from __future__ import absolute_import | 9 from __future__ import absolute_import |
10 | 10 |
11 import BaseHTTPServer | |
12 import errno | 11 import errno |
13 import mimetypes | 12 import mimetypes |
14 import os | 13 import os |
14 | |
15 from .. import util | |
16 | |
17 httpserver = util.httpserver | |
15 | 18 |
16 HTTP_OK = 200 | 19 HTTP_OK = 200 |
17 HTTP_NOT_MODIFIED = 304 | 20 HTTP_NOT_MODIFIED = 304 |
18 HTTP_BAD_REQUEST = 400 | 21 HTTP_BAD_REQUEST = 400 |
19 HTTP_UNAUTHORIZED = 401 | 22 HTTP_UNAUTHORIZED = 401 |
105 if attr in ('close', 'readline', 'readlines', '__iter__'): | 108 if attr in ('close', 'readline', 'readlines', '__iter__'): |
106 return getattr(self.f, attr) | 109 return getattr(self.f, attr) |
107 raise AttributeError | 110 raise AttributeError |
108 | 111 |
109 def _statusmessage(code): | 112 def _statusmessage(code): |
110 responses = BaseHTTPServer.BaseHTTPRequestHandler.responses | 113 responses = httpserver.basehttprequesthandler.responses |
111 return responses.get(code, ('Error', 'Unknown error'))[0] | 114 return responses.get(code, ('Error', 'Unknown error'))[0] |
112 | 115 |
113 def statusmessage(code, message=None): | 116 def statusmessage(code, message=None): |
114 return '%d %s' % (code, message or _statusmessage(code)) | 117 return '%d %s' % (code, message or _statusmessage(code)) |
115 | 118 |