diff options
author | Paul Smith <prs247au@gmail.com> | 2017-05-20 10:56:51 +1000 |
---|---|---|
committer | Paul Smith <prs247au@gmail.com> | 2017-05-20 10:56:51 +1000 |
commit | 9edb32cf07c332805b53f1772e7bdefa1d2d4983 (patch) | |
tree | 96e6f1519c86b6655cd1c4ed38126ec1d0868903 /jsonrpclib/SimpleJSONRPCServer.py | |
parent | 3789355028206a63b2d161a9c47c5e2d0b212b32 (diff) | |
download | jsonrpclib-9edb32cf07c332805b53f1772e7bdefa1d2d4983.tar.gz |
Put in some changes suggested by Josh
Diffstat (limited to 'jsonrpclib/SimpleJSONRPCServer.py')
-rw-r--r-- | jsonrpclib/SimpleJSONRPCServer.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/jsonrpclib/SimpleJSONRPCServer.py b/jsonrpclib/SimpleJSONRPCServer.py index cf48a66..290fafa 100644 --- a/jsonrpclib/SimpleJSONRPCServer.py +++ b/jsonrpclib/SimpleJSONRPCServer.py @@ -2,11 +2,11 @@ import jsonrpclib from jsonrpclib import Fault from jsonrpclib.jsonrpc import USE_UNIX_SOCKETS try: - import SimpleXMLRPCServer - import SocketServer -except ImportError: - import xmlrpc.server as SimpleXMLRPCServer + import xmlrpc.server as SimpleXMLRPCServer # Python 3.x import socketserver as SocketServer +except ImportError: + import SimpleXMLRPCServer # Python 2.7 + import SocketServer import socket import logging import os @@ -17,11 +17,11 @@ try: except ImportError: # For Windows fcntl = None + try: - string_types = (str, unicode) + basestring # Python 2.7 except NameError: - string_types = (str, ) - + basestring = str # Python 3.x def get_version(request): # must be a dict @@ -46,7 +46,7 @@ def validate_request(request): request.setdefault('params', []) method = request.get('method', None) params = request.get('params') - if not method or not isinstance(method, string_types) or \ + if not method or not isinstance(method, basestring) or \ not isinstance(params, (list, dict, tuple)): fault = Fault( -32600, 'Invalid request parameters or method.', rpcid=rpcid @@ -177,7 +177,6 @@ class SimpleJSONRPCRequestHandler( response = self.server._marshaled_dispatch(data) self.send_response(200) except Exception as ex: - print('Exception in do_POST(): %s'%ex) self.send_response(500) err_lines = traceback.format_exc().splitlines() trace_string = '%s | %s' % (err_lines[-3], err_lines[-1]) |