diff options
| author | Martin v. Löwis <martin@v.loewis.de> | 2006-11-19 18:51:54 (GMT) | 
|---|---|---|
| committer | Martin v. Löwis <martin@v.loewis.de> | 2006-11-19 18:51:54 (GMT) | 
| commit | 07529354dba821ddfa8ee0a14a9302e352eb8173 (patch) | |
| tree | 48143b330356fc0f25a75dbecbb66e48e8f17740 /Lib/xmlrpclib.py | |
| parent | 9eec51c04ff9d04c74724aa6cd499457b64c75f9 (diff) | |
| download | cpython-07529354dba821ddfa8ee0a14a9302e352eb8173.zip cpython-07529354dba821ddfa8ee0a14a9302e352eb8173.tar.gz cpython-07529354dba821ddfa8ee0a14a9302e352eb8173.tar.bz2  | |
Patch #1070046: Marshal new-style objects like InstanceType
in xmlrpclib.
Diffstat (limited to 'Lib/xmlrpclib.py')
| -rw-r--r-- | Lib/xmlrpclib.py | 16 | 
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py index 6fb6c68..3864dad 100644 --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -630,9 +630,19 @@ class Marshaller:          try:              f = self.dispatch[type(value)]          except KeyError: -            raise TypeError, "cannot marshal %s objects" % type(value) -        else: -            f(self, value, write) +            # check if this object can be marshalled as a structure +            try: +                value.__dict__ +            except: +                raise TypeError, "cannot marshal %s objects" % type(value) +            # check if this class is a sub-class of a basic type, +            # because we don't know how to marshal these types +            # (e.g. a string sub-class) +            for type_ in type(value).__mro__: +                if type_ in self.dispatch.keys(): +                    raise TypeError, "cannot marshal %s objects" % type(value) +            f = self.dispatch[InstanceType] +        f(self, value, write)      def dump_nil (self, value, write):          if not self.allow_none:  | 
