Message10467
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 |
|
Date |
User |
Action |
Args |
2015-11-12 23:53:10 | pekka.klarck | set | recipients:
+ pekka.klarck |
2015-11-12 23:53:10 | pekka.klarck | set | messageid: <1447372390.19.0.91067615768.issue2429@psf.upfronthosting.co.za> |
2015-11-12 23:53:10 | pekka.klarck | link | issue2429 messages |
2015-11-12 23:53:08 | pekka.klarck | create | |
|