Skip to content

Commit b5025ae

Browse files
author
yucetekol
committed
SimpleJSONRPCServer works on Python 2.5
git-svn-id: http://jsonrpclib.googlecode.com/svn/trunk@14 ae587032-bbab-11de-869a-473eb4776397
1 parent 669c136 commit b5025ae

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

jsonrpclib/SimpleJSONRPCServer.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,15 @@ def __init__(self, addr, requestHandler=SimpleJSONRPCRequestHandler,
159159
logRequests=True, encoding=None, bind_and_activate=True):
160160
self.logRequests = logRequests
161161
SimpleJSONRPCDispatcher.__init__(self, encoding)
162-
SocketServer.TCPServer.__init__(self, addr, requestHandler,
163-
bind_and_activate)
162+
# TCPServer.__init__ has an extra parameter on 2.6+, so
163+
# check Python version and decide on how to call it
164+
vi = sys.version_info
165+
# if python 2.5 and lower
166+
if vi[0] < 3 and vi[1] < 6:
167+
SocketServer.TCPServer.__init__(self, addr, requestHandler)
168+
else:
169+
SocketServer.TCPServer.__init__(self, addr, requestHandler,
170+
bind_and_activate)
164171
if fcntl is not None and hasattr(fcntl, 'FD_CLOEXEC'):
165172
flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD)
166173
flags |= fcntl.FD_CLOEXEC

0 commit comments

Comments
 (0)