Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default int value with xmlrpclib / xmlrpc.client #71329

Closed
julienc91 mannequin opened this issue May 27, 2016 · 3 comments
Closed

Default int value with xmlrpclib / xmlrpc.client #71329

julienc91 mannequin opened this issue May 27, 2016 · 3 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir topic-XML type-feature A feature request or enhancement

Comments

@julienc91
Copy link
Mannequin

julienc91 mannequin commented May 27, 2016

BPO 27142
Nosy @loewis, @rhettinger, @serhiy-storchaka, @julienc91

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2017-11-09.17:57:10.845>
created_at = <Date 2016-05-27.22:17:42.192>
labels = ['expert-XML', 'type-feature', 'library', '3.7']
title = 'Default int value with xmlrpclib / xmlrpc.client'
updated_at = <Date 2017-11-09.17:57:10.844>
user = 'https://github.com/julienc91'

bugs.python.org fields:

activity = <Date 2017-11-09.17:57:10.844>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2017-11-09.17:57:10.845>
closer = 'serhiy.storchaka'
components = ['Library (Lib)', 'XML']
creation = <Date 2016-05-27.22:17:42.192>
creator = 'julienc'
dependencies = []
files = []
hgrepos = []
issue_num = 27142
keywords = []
message_count = 3.0
messages = ['266517', '266533', '282046']
nosy_count = 4.0
nosy_names = ['loewis', 'rhettinger', 'serhiy.storchaka', 'julienc']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue27142'
versions = ['Python 3.7']

@julienc91
Copy link
Mannequin Author

julienc91 mannequin commented May 27, 2016

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.

@julienc91 julienc91 mannequin added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir topic-XML labels May 27, 2016
@serhiy-storchaka
Copy link
Member

XML-RPC Specification: http://xmlrpc.scripting.com/spec.html .

@serhiy-storchaka
Copy link
Member

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?

@serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Nov 29, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir topic-XML type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant