New submission from Julien:
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.
----------
components: Library (Lib), XML
messages: 266517
nosy: julienc
priority: normal
severity: normal
status: open
title: Default int value with xmlrpclib / xmlrpc.client
type: behavior
versions: Python 2.7, Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27142>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com