New submission from Kostis ankostis: 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 ---------- assignee: docs@python components: Demos and Tools, Documentation messages: 250518 nosy: Kostis ankostis, docs@python priority: normal severity: normal status: open title: The example-code for making XLM-RPC requests through proxy, fail! versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25080> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com