diff options
author | Petr Motejlek <petr@motejlek.net> | 2017-03-01 17:21:28 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-01 17:21:28 (GMT) |
commit | 3c6314c08d8ab1cfefbf6c2e27c095a7d4ba5f6e (patch) | |
tree | dd7b4ce05680b683cd882798a3fc42e6bd8b2069 /Lib/xmlrpc | |
parent | da62373b0d32c14a4137512ef6f13c24fbcaa2c1 (diff) | |
download | cpython-3c6314c08d8ab1cfefbf6c2e27c095a7d4ba5f6e.zip cpython-3c6314c08d8ab1cfefbf6c2e27c095a7d4ba5f6e.tar.gz cpython-3c6314c08d8ab1cfefbf6c2e27c095a7d4ba5f6e.tar.bz2 |
bpo-29615: SimpleXMLRPCDispatcher no longer chains KeyError (#260)
(or any other exception) to exception(s) raised in the dispatched methods.
Patch by Petr Motejlek.
Diffstat (limited to 'Lib/xmlrpc')
-rw-r--r-- | Lib/xmlrpc/server.py | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py index a6275a1..bb86fe6 100644 --- a/Lib/xmlrpc/server.py +++ b/Lib/xmlrpc/server.py @@ -392,31 +392,36 @@ class SimpleXMLRPCDispatcher: not be called. """ - func = None try: - # check to see if a matching function has been registered + # call the matching registered function func = self.funcs[method] except KeyError: - if self.instance is not None: - # check for a _dispatch method - if hasattr(self.instance, '_dispatch'): - return self.instance._dispatch(method, params) - else: - # call instance method directly - try: - func = resolve_dotted_attribute( - self.instance, - method, - self.allow_dotted_names - ) - except AttributeError: - pass - - if func is not None: - return func(*params) + pass else: + if func is not None: + return func(*params) raise Exception('method "%s" is not supported' % method) + if self.instance is not None: + if hasattr(self.instance, '_dispatch'): + # call the `_dispatch` method on the instance + return self.instance._dispatch(method, params) + + # call the instance's method directly + try: + func = resolve_dotted_attribute( + self.instance, + method, + self.allow_dotted_names + ) + except AttributeError: + pass + else: + if func is not None: + return func(*params) + + raise Exception('method "%s" is not supported' % method) + class SimpleXMLRPCRequestHandler(BaseHTTPRequestHandler): """Simple XML-RPC request handler class. |