[Python-bugs-list] [ python-Bugs-469972 ] xmlrpclib won't marshal new types (original) (raw)

noreply@sourceforge.net noreply@sourceforge.net
Fri, 19 Oct 2001 09:00:18 -0700


Bugs item #469972, was opened at 2001-10-10 12:36 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=469972&group_id=5470

Category: Python Library Group: Python 2.2 Status: Open Resolution: None Priority: 5 Submitted By: Skip Montanaro (montanaro) Assigned to: Nobody/Anonymous (nobody) Summary: xmlrpclib won't marshal new types

Initial Comment: Maybe xmlrpclib should be modified to allow it to marshal subclasses of builtin types (ints, strings, etc). Here's a simple example that demonstrates that it currently won't work with a subclass of str:

import xmlrpclib class MyString(str): ... pass ... s = MyString("sdfsdfsdf") s 'sdfsdfsdf' s.class <class '__main__.MyString'> xmlrpclib.dumps((s,)) Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.2/xmlrpclib.py", line 752, in dumps data = m.dumps(params) File "/usr/local/lib/python2.2/xmlrpclib.py", line 448, in dumps self.__dump(v) File "/usr/local/lib/python2.2/xmlrpclib.py", line 459, in __dump raise TypeError, "cannot marshal %s objects" % type(value) TypeError: cannot marshal <class '__main__.MyString'> objects


Comment By: Skip Montanaro (montanaro) Date: 2001-10-19 09:00

Message: Logged In: YES user_id=44345

I don't think #471893 applies here. While xmlrpclib will marshal the dict of an instance object, it is seen as a marshalled dict at the other end and would be unmarshalled as a dict without special effort on the part of the programmer. XML-RPC only supports a small, fixed set of types: ints, booleans, floats, date-time strings, lists and dicts.

My concern with allowing XML-RPC marshalling of a subclass of strings (for example), is that the programmer might be led to believe their extra instance attributes would be marshalled as well. While I submitted this bug report, I was simply recording someone else's observation.


Comment By: paul rubin (phr) Date: 2001-10-19 07:16

Message: Logged In: YES user_id=72053

  1. anything but the base types aren't part of the xmlrpc spec

  2. be very very careful about unmarshalling any but basic objects, because of possible security attacks. See item 471893 for some more info.


You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=469972&group_id=5470