Skip to content

Commit 3bfbaf0

Browse files
committed
Python 3 preparation: update BaseHTTPServer imports.
roundup/anypy/http_.py extended and used in more places. Manual patch.
1 parent 43832a8 commit 3bfbaf0

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

roundup/anypy/http_.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
try:
22
# Python 3+
3-
from http import client
3+
from http import client, server
44
except:
55
# Python 2.5-2.7
66
import httplib as client
7+
import BaseHTTPServer as server
78

roundup/cgi/wsgi_handler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
import roundup.instance
1212
from roundup.cgi import TranslationService
13-
from BaseHTTPServer import BaseHTTPRequestHandler, DEFAULT_ERROR_MESSAGE
13+
from roundup.anypy import http_
14+
BaseHTTPRequestHandler = http_.server.BaseHTTPRequestHandler
15+
DEFAULT_ERROR_MESSAGE = http_.server.DEFAULT_ERROR_MESSAGE
1416

1517

1618
class Writer(object):

roundup/scripts/roundup_server.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838

3939
import errno, cgi, getopt, os, socket, sys, traceback, time
40-
import BaseHTTPServer, SocketServer, StringIO
40+
import SocketServer, StringIO
4141

4242
try:
4343
# Python 2.
@@ -56,7 +56,7 @@
5656
from roundup import __version__ as roundup_version
5757

5858
# Roundup modules of use here
59-
from roundup.anypy import urllib_
59+
from roundup.anypy import http_, urllib_
6060
from roundup.cgi import cgitb, client
6161
from roundup.cgi.PageTemplates.PageTemplate import PageTemplate
6262
import roundup.instance
@@ -116,10 +116,10 @@ def auto_ssl():
116116

117117
return ctx
118118

119-
class SecureHTTPServer(BaseHTTPServer.HTTPServer):
119+
class SecureHTTPServer(http_.server.HTTPServer):
120120
def __init__(self, server_address, HandlerClass, ssl_pem=None):
121121
assert SSL, "pyopenssl not installed"
122-
BaseHTTPServer.HTTPServer.__init__(self, server_address, HandlerClass)
122+
http_.server.HTTPServer.__init__(self, server_address, HandlerClass)
123123
self.socket = socket.socket(self.address_family, self.socket_type)
124124
if ssl_pem:
125125
ctx = SSL.Context(SSL.SSLv23_METHOD)
@@ -177,7 +177,7 @@ def __getattr__(self, attrib):
177177
conn = ConnFixer(conn)
178178
return (conn, info)
179179

180-
class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
180+
class RoundupRequestHandler(http_.server.BaseHTTPRequestHandler):
181181
TRACKER_HOMES = {}
182182
TRACKERS = None
183183
LOG_IPADDRESS = 1
@@ -457,7 +457,7 @@ def log_message(self, format, *args):
457457
format%args))
458458
else:
459459
try:
460-
BaseHTTPServer.BaseHTTPRequestHandler.log_message(self,
460+
http_.server.BaseHTTPRequestHandler.log_message(self,
461461
format, *args)
462462
except IOError:
463463
# stderr is no longer viable
@@ -702,7 +702,7 @@ def finish(self):
702702
# socket, so we do this only for non-SSL connections.
703703
if hasattr(socket, 'setdefaulttimeout'):
704704
socket.setdefaulttimeout(60)
705-
base_server = BaseHTTPServer.HTTPServer
705+
base_server = http_.server.HTTPServer
706706

707707
# obtain request server class
708708
if self["MULTIPROCESS"] not in MULTIPROCESS_TYPES:

0 commit comments

Comments
 (0)