]> granicus.if.org Git - python/commitdiff
Issue #13293: Better error message when trying to marshal bytes using xmlrpc.client.
authorFlorent Xicluna <florent.xicluna@gmail.com>
Sun, 30 Oct 2011 19:22:25 +0000 (20:22 +0100)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Sun, 30 Oct 2011 19:22:25 +0000 (20:22 +0100)
Lib/xmlrpc/client.py
Misc/NEWS

index bd59f326fbe2c22d2d92c34f848f7f1c2f22eeeb..97d5aac53d5b97cd9d0c42becbc726b7b1f2faaf 100644 (file)
@@ -503,9 +503,7 @@ class Marshaller:
             f = self.dispatch[type(value)]
         except KeyError:
             # check if this object can be marshalled as a structure
-            try:
-                value.__dict__
-            except:
+            if not hasattr(value, '__dict__'):
                 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
@@ -553,12 +551,6 @@ class Marshaller:
         write("</double></value>\n")
     dispatch[float] = dump_double
 
-    def dump_string(self, value, write, escape=escape):
-        write("<value><string>")
-        write(escape(value))
-        write("</string></value>\n")
-    dispatch[bytes] = dump_string
-
     def dump_unicode(self, value, write, escape=escape):
         write("<value><string>")
         write(escape(value))
index 80c435a3ada556c4979027c7040b7a7bf77f7dda..70572b41cd7cbd01b3635cef39703137cfdd0a6e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -63,6 +63,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #13293: Better error message when trying to marshal bytes using
+  xmlrpc.client.
+
 - Issue #13291: NameError in xmlrpc package.
 
 - Issue #13258: Use callable() built-in in the standard library.