From: yucetekol Date: Tue, 3 Nov 2009 14:15:54 +0000 (+0000) Subject: SimpleJSONRPCServer works on Python 2.5 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/python-jsonrpclib.git/commitdiff_plain/b5025aec62d8ff49304a36bc9a2e9a37b912ba1c SimpleJSONRPCServer works on Python 2.5 git-svn-id: http://jsonrpclib.googlecode.com/svn/trunk@14 ae587032-bbab-11de-869a-473eb4776397 --- diff --git a/jsonrpclib/SimpleJSONRPCServer.py b/jsonrpclib/SimpleJSONRPCServer.py index ae41f93..bf903ea 100644 --- a/jsonrpclib/SimpleJSONRPCServer.py +++ b/jsonrpclib/SimpleJSONRPCServer.py @@ -159,8 +159,15 @@ class SimpleJSONRPCServer(SocketServer.TCPServer, logRequests=True, encoding=None, bind_and_activate=True): self.logRequests = logRequests SimpleJSONRPCDispatcher.__init__(self, encoding) - SocketServer.TCPServer.__init__(self, addr, requestHandler, - bind_and_activate) + # TCPServer.__init__ has an extra parameter on 2.6+, so + # check Python version and decide on how to call it + vi = sys.version_info + # if python 2.5 and lower + if vi[0] < 3 and vi[1] < 6: + SocketServer.TCPServer.__init__(self, addr, requestHandler) + else: + SocketServer.TCPServer.__init__(self, addr, requestHandler, + bind_and_activate) if fcntl is not None and hasattr(fcntl, 'FD_CLOEXEC'): flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD) flags |= fcntl.FD_CLOEXEC