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.

Author ankostis
Recipients ankostis, docs@python
Date 2015-09-12.12:08:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1442059715.67.0.31958758043.issue25080@psf.upfronthosting.co.za>
In-reply-to
Content
The example code provided at the bottom of the reference-page: 
  https://docs.python.org/2/library/xmlrpclib.html#example-of-client-usage
for making XML-RPC requests through a proxy by defining a custom transport fails (at least) in python-3.4!

Obviously it has been kept intact from `xmlrpclib` python-2 but `xmlrpc.client` API has changed and consequently the code fails.
Here is a IPython session demonstratin the problem:

    >>> import xmlrpc.client, http.client
    >>>
    >>> class ProxiedTransport(xmlrpc.client.Transport):
    ...     def set_proxy(self, proxy):
    ...         self.proxy = proxy
    ...     def make_connection(self, host):
    ...         self.realhost = host
    ...         h = http.client.HTTP(self.proxy)
    ...         return h
    ...     def send_request(self, connection, handler, request_body):
    ...         connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
    ...     def send_host(self, connection, host):
    ...         connection.putheader('Host', self.realhost)
    ...
    >>> p = ProxiedTransport()
    >>> p.set_proxy('proxy-server:8080')
    >>> server = xmlrpc.client.Server('http://time.xmlrpc.com/RPC2', transport=p)
    >>> print(server.currentTime.getCurrentTime())
    Traceback (most recent call last):
      File "D:\Apps\WinPython-64bit-3.4.3.4\python-3.4.3.amd64\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code
        exec(code_obj, self.user_global_ns, self.user_ns)
      File "<ipython-input-43-7f4e26b6cd8f>", line 1, in <module>
        print(server.currentTime.getCurrentTime())
      File "D:\Apps\WinPython-64bit-3.4.3.4\python-3.4.3.amd64\lib\xmlrpc\client.py", line 1098, in __call__
        return self.__send(self.__name, args)
      File "D:\Apps\WinPython-64bit-3.4.3.4\python-3.4.3.amd64\lib\xmlrpc\client.py", line 1437, in __request
        verbose=self.__verbose
      File "D:\Apps\WinPython-64bit-3.4.3.4\python-3.4.3.amd64\lib\xmlrpc\client.py", line 1140, in request
        return self.single_request(host, handler, request_body, verbose)
      File "D:\Apps\WinPython-64bit-3.4.3.4\python-3.4.3.amd64\lib\xmlrpc\client.py", line 1152, in single_request
        http_conn = self.send_request(host, handler, request_body, verbose)
    TypeError: send_request() takes 4 positional arguments but 5 were given
History
Date User Action Args
2015-09-12 12:08:35ankostissetrecipients: + ankostis, docs@python
2015-09-12 12:08:35ankostissetmessageid: <1442059715.67.0.31958758043.issue25080@psf.upfronthosting.co.za>
2015-09-12 12:08:35ankostislinkissue25080 messages
2015-09-12 12:08:34ankostiscreate