Author petr@motejlek.net
Recipients petr@motejlek.net
Date 2017-02-21.20:30:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487709025.37.0.198613157816.issue29615@psf.upfronthosting.co.za>
In-reply-to
Content
Hello,

We discovered that SimpleXMLRPCDispatcher mangles tracebacks printed from within the invoked RPC methods when an object that has _dispatch(method, params) defined has been registered with it

Steps to reproduce
- use https://docs.python.org/3.4/library/xmlrpc.server.html#xmlrpc.server.SimpleXMLRPCServer.register_instance and register within SimpleXMLRPCDispatcher an object with the _dispatch(method, params) method defined
- invoke any RPC method that prints a traceback (perhaps raise an exception in it, catch it and use logging.exception to log it) --> the traceback will display a very strange looking KeyError (its value being the name of the invoked method) and then the actual exception that was fed into logging.exception

The reason for this is that SimpleXMLRPCDispatcher._dispatch first attempts to acquire the function to invoke by reading from the functions registered with the dispatcher. When this attempt fails, KeyError is raised. During its handling different approaches are taken to acquire the function and for all but one when the function is acquired, handling of the KeyError ends and the function is called properly, outside of the except block

However, in the case of objects that define the _dispatch(method, params) function, the _dispatch(method, params) function is called straight away, still within the except block handling the KeyError, and this leads to the mangled traceback

This behavior is neither documented, nor expected (we believe) and thus the code should be changed

Will submit a PR (incl. tests) for this later on
History
Date User Action Args
2017-02-21 20:30:25petr@motejlek.netsetrecipients: + petr@motejlek.net
2017-02-21 20:30:25petr@motejlek.netsetmessageid: <1487709025.37.0.198613157816.issue29615@psf.upfronthosting.co.za>
2017-02-21 20:30:25petr@motejlek.netlinkissue29615 messages
2017-02-21 20:30:25petr@motejlek.netcreate