This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SimpleXMLRPCDispatcher._dispatch mangles tracebacks when invoking RPC calls through _dispatch
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: loewis, petr@motejlek.net, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-02-21 20:30 by petr@motejlek.net, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 260 merged petr@motejlek.net, 2017-02-23 20:07
PR 478 merged petr@motejlek.net, 2017-03-05 15:13
PR 479 merged petr@motejlek.net, 2017-03-05 15:27
PR 703 larry, 2017-03-17 21:00
PR 552 closed dstufft, 2017-03-31 16:36
Messages (4)
msg288319 - (view) Author: Petr MOTEJLEK (petr@motejlek.net) * Date: 2017-02-21 20:30
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
msg290297 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:54
New changeset c6e199f2e9a2514c3fd220aaa4bd23fa1d6da8c9 by Serhiy Storchaka (Petr Motejlek) in branch '3.5':
bpo-29615: backport to 3.5 (#479)
https://github.com/python/cpython/commit/c6e199f2e9a2514c3fd220aaa4bd23fa1d6da8c9
msg290298 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:54
New changeset 3405792b024e9c6b70c0d2355c55a23ac84e1e67 by Serhiy Storchaka (Petr Motejlek) in branch '3.6':
bpo-29615: backport to 3.6 (#478)
https://github.com/python/cpython/commit/3405792b024e9c6b70c0d2355c55a23ac84e1e67
msg290351 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 23:30
New changeset 3c6314c08d8ab1cfefbf6c2e27c095a7d4ba5f6e by Serhiy Storchaka (Petr Motejlek) in branch 'master':
bpo-29615: SimpleXMLRPCDispatcher no longer chains KeyError (#260)
https://github.com/python/cpython/commit/3c6314c08d8ab1cfefbf6c2e27c095a7d4ba5f6e
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73801
2017-03-31 16:36:09dstufftsetpull_requests: + pull_request854
2017-03-24 23:30:15serhiy.storchakasetmessages: + msg290351
2017-03-24 22:54:40serhiy.storchakasetmessages: + msg290298
2017-03-24 22:54:17serhiy.storchakasetmessages: + msg290297
2017-03-17 21:13:55serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-03-17 21:00:33larrysetpull_requests: + pull_request595
2017-03-05 15:27:01petr@motejlek.netsetpull_requests: + pull_request392
2017-03-05 15:13:27petr@motejlek.netsetpull_requests: + pull_request391
2017-02-24 08:10:05serhiy.storchakasetnosy: + loewis, serhiy.storchaka
stage: patch review
type: behavior

versions: - Python 3.4
2017-02-23 20:07:01petr@motejlek.netsetpull_requests: + pull_request231
2017-02-21 20:30:25petr@motejlek.netcreate