Message266517
I tried to execute the following code, but `xmlrpclib` is raising an exception:
>>> import xmlrpclib
>>> data = """<?xml version="1.0"?>
... <methodCall>
... <methodName>test_method</methodName>
... <params>
... <param>
... <value>
... <int/>
... </value>
... </param>
... </params>
... </methodCall>"""
>>> xmlrpclib.loads(data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/xmlrpclib.py", line 1141, in loads
p.feed(data)
File "/usr/lib64/python2.7/xmlrpclib.py", line 558, in feed
self._parser.Parse(data, 0)
File "/usr/lib64/python2.7/xmlrpclib.py", line 829, in end
return f(self, join(self._data, ""))
File "/usr/lib64/python2.7/xmlrpclib.py", line 864, in end_int
self.append(int(data))
ValueError: invalid literal for int() with base 10: ''
The behaviour is the same with `<int></int>`, and in python 3.4 with xmlrpc.client .
However, I tried to parse the same data with PHP, and it works without any trouble.
php > $data = '<?xml version="1.0"?><methodCall><methodName>test_method</methodName><params><param><value><int/></value></param></params></methodCall>';
php > print_r(xmlrpc_decode($data));
Array
(
[0] => 0
)
The .NET documentation of XML-RPC also suggests that `<int/>` is interpreted as 0 (although I couldn't try it myself):
> If an XML-RPC struct member is missing its corresponding .NET struct member will be set to null instead of the default value for the type if a non-nullable type had been used, for example null instead of zero for an integer.
Is it a feature in .NET and PHP implementations of XML-RPC, or a bug in the python implementation? I didn't find any documentation about the XML-RPC protocol itself on this topic. |
|
Date |
User |
Action |
Args |
2016-05-27 22:17:42 | julienc | set | recipients:
+ julienc |
2016-05-27 22:17:42 | julienc | set | messageid: <1464387462.23.0.765030008479.issue27142@psf.upfronthosting.co.za> |
2016-05-27 22:17:42 | julienc | link | issue27142 messages |
2016-05-27 22:17:41 | julienc | create | |
|