SimpleJSONRPCServer works on Python 2.5
authoryucetekol <yucetekol@ae587032-bbab-11de-869a-473eb4776397>
Tue, 3 Nov 2009 14:15:54 +0000 (14:15 +0000)
committeryucetekol <yucetekol@ae587032-bbab-11de-869a-473eb4776397>
Tue, 3 Nov 2009 14:15:54 +0000 (14:15 +0000)
git-svn-id: http://jsonrpclib.googlecode.com/svn/trunk@14 ae587032-bbab-11de-869a-473eb4776397

jsonrpclib/SimpleJSONRPCServer.py

index ae41f93..bf903ea 100644 (file)
@@ -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