This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Default int value with xmlrpclib / xmlrpc.client
Type: enhancement Stage: resolved
Components: Library (Lib), XML Versions: Python 3.7
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: julienc, loewis, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2016-05-27 22:17 by julienc, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg266517 - (view) Author: Julien (julienc) Date: 2016-05-27 22:17
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/", line 1141, in loads
      File "/usr/lib64/python2.7/", line 558, in feed
        self._parser.Parse(data, 0)
      File "/usr/lib64/python2.7/", line 829, in end
        return f(self, join(self._data, ""))
      File "/usr/lib64/python2.7/", line 864, in end_int
    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));
        [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.
msg266533 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-28 05:39
XML-RPC Specification: .
msg282046 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-11-29 20:46
This format doesn't conform the XML-RPC specification. Adding the support of it is a new feature. The question is whether there is a need of this feature. Are there some common XML-RPC servers or clients that produce such format?
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71329
2017-11-09 17:57:10serhiy.storchakasetstatus: pending -> closed
resolution: rejected
stage: resolved
2017-10-23 14:07:12serhiy.storchakasetstatus: open -> pending
2016-11-30 04:53:13rhettingersetnosy: + rhettinger
2016-11-29 20:46:06serhiy.storchakasettype: behavior -> enhancement
messages: + msg282046
versions: + Python 3.7, - Python 2.7, Python 3.4
2016-05-28 05:39:49serhiy.storchakasetnosy: + loewis, serhiy.storchaka
messages: + msg266533
2016-05-27 22:17:42julienccreate