Issue #791 resolved

cherrypy.lib.xmlrpc.respond cannot marshal xmlrpclib.Fault objects

Anonymous created an issue

When using {{{xmlrpclib.dumps}}} it is perfectly legal and accepted to pass in an {{{xmlrpclib.Fault}}} instance to signify an application error. Currently, {{{cherrypy.lib.xmlrpc.respond}}} wraps all body content inside a tuple causing the underlying {{{xmlrpclib.dumps}}} function to be unable to marshal xmlrpclib.Fault objects.

The current code:



def respond(body, encoding='utf-8', allow_none=0): import xmlrpclib _set_response(xmlrpclib.dumps((body,), methodresponse=1, encoding=encoding, allow_none=allow_none)) }}}

Really should be replaced with something like:



def respond(body, encoding='utf-8', allow_none=0): if not isinstance(body, xmlrpclib.Fault): body = (body,) _set_response(xmlrpclib.dumps(body, methodresponse=1, encoding=encoding, allow_none=allow_none)) }}}

Reported by

Comments (2)

  1. Log in to comment