[New-bugs-announce] [issue13397] Option for XMLRPC clients to automatically transform Fault exceptions into standard exceptions

Raymond Hettinger report at bugs.python.org
Sun Nov 13 22:00:30 CET 2011


New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:

Currently, an XMLRPC client communicating with a server running Python can make Python style calls but exceptions get collapsed into a standard FaultException making it difficult to program in a Pythonic style:

proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
try:
    value = proxy.lookup('somekey')
except xmlrpc.client.Fault as err:
    if err.faultCode == 1 and 'KeyError' in err.faultString:
        k = re.search(r":.(\w+)' not found$", err.faultString).groups(1)
        raise KeyError(k)
 
It would be better if we could do this automatically (search for a pure python exception of the same name and raise it instead of a Fault):

proxy = xmlrpc.client.ServerProxy("http://localhost:8000/", python_exceptions=True)

try:
   value = proxy.lookup('somekey')
except KeyError as e:
   ...

----------
messages: 147572
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Option for XMLRPC clients to automatically transform Fault exceptions into standard exceptions
type: feature request
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13397>
_______________________________________


More information about the New-bugs-announce mailing list