From: Pekka K. <re...@bu...> - 2015-11-12 23:53:17
|
New submission from Pekka Klärck: To reprocude: 1) First start XML-RPC server: Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_66 Type "help", "copyright", "credits" or "license" for more information. >>> from SimpleXMLRPCServer import SimpleXMLRPCServer >>> server = SimpleXMLRPCServer(('127.0.0.1', 12345)) >>> def func(arg): ... return repr(arg.data) ... >>> server.register_function(func) >>> server.serve_forever() 2) Use the server with Binary wrapping bytes (i.e. str) and bytearray: Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_66 Type "help", "copyright", "credits" or "license" for more information. >>> import xmlrpclib >>> proxy = xmlrpclib.ServerProxy('http://127.0.0.1:12345') >>> proxy.func(xmlrpclib.Binary(b'foo')) # works fine "'foo'" >>> proxy.func(xmlrpclib.Binary(bytearray(b'foo'))) # bang!! Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/peke/Prog/jython2.7.0/Lib/xmlrpclib.py", line 1224, in __call__ return self.__send(self.__name, args) File "/home/peke/Prog/jython2.7.0/Lib/xmlrpclib.py", line 1571, in _ServerProxy__request request = dumps(params, methodname, encoding=self.__encoding, File "/home/peke/Prog/jython2.7.0/Lib/xmlrpclib.py", line 1085, in dumps data = m.dumps(params) File "/home/peke/Prog/jython2.7.0/Lib/xmlrpclib.py", line 632, in dumps dump(v, write) File "/home/peke/Prog/jython2.7.0/Lib/xmlrpclib.py", line 654, in _Marshaller__dump f(self, value, write) File "/home/peke/Prog/jython2.7.0/Lib/xmlrpclib.py", line 752, in dump_instance value.encode(self) File "/home/peke/Prog/jython2.7.0/Lib/xmlrpclib.py", line 506, in encode base64.encode(StringIO.StringIO(self.data), out) TypeError: StringIO(): 1st arg can't be coerced to String, org.python.core.PyArray ---------- messages: 10467 nosy: pekka.klarck severity: normal status: open title: Sending bytearray wrapped to xmlrpc.Binary over XML-RPC fails _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue2429> _______________________________________ |