classification
Title: SimpleXMLRPCServer Example uses "mul" instead of "div" in client portion
Type: Stage:
Components: Documentation Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, mnewman
Priority: normal Keywords:

Created on 2010-01-30 16:23 by mnewman, last changed 2010-01-30 17:54 by georg.brandl. This issue is now closed.

Messages (2)
msg98567 - (view) Author: Michael Newman (mnewman) Date: 2010-01-30 16:23
In "20.24.1.1. SimpleXMLRPCServer Example":
http://docs.python.org/3.1/library/xmlrpc.server.html

The client portion of the example uses "mul", which does not exist in the server portion. The easiest fix to change the client to use "div" instead of "mul".

# Attempt to use client code exactly as provided:
# Python 3.1.1 (r311:74483) on win32
E:\notes\Programming\python3\lib\xmlrpc.server>py31 example1_xmlrpc_client.py
8
5
Traceback (most recent call last):
  File "example1_xmlrpc_client.py", line 11, in <module>
    print(s.mul(5,2))  # Returns 5*2 = 10
  File "C:\python31\lib\xmlrpc\client.py", line 1029, in __call__
    return self.__send(self.__name, args)
  File "C:\python31\lib\xmlrpc\client.py", line 1271, in __request
    verbose=self.__verbose
  File "C:\python31\lib\xmlrpc\client.py", line 1070, in request
    return self.parse_response(resp)
  File "C:\python31\lib\xmlrpc\client.py", line 1169, in parse_response
    return u.close()
  File "C:\python31\lib\xmlrpc\client.py", line 673, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 1: '<class \'Exception\'>:method "mul" is not supported'>

To fix it, I changed this line in the client code:

print(s.mul(5,2))  # Returns 5*2 = 10

to:

print(s.div(8,2))  # Returns 8/2 = 4

# Here's how it now looks after the suggested fix:
E:\notes\Programming\python3\lib\xmlrpc.server>py31 example1_xmlrpc_client_rev1.
py
8
5
4
['add', 'div', 'pow', 'system.listMethods', 'system.methodHelp', 'system.methodSignature']
msg98570 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-01-30 17:54
Thanks, fixed in r77857.
History
Date User Action Args
2010-01-30 17:54:23georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg98570
2010-01-30 16:23:38mnewmancreate