[Python-checkins] cpython (3.2): Issue #13293: Better error message when trying to marshal bytes using

florent.xicluna python-checkins at python.org
Sun Oct 30 20:26:49 CET 2011


http://hg.python.org/cpython/rev/013d2881beb5
changeset:   73215:013d2881beb5
branch:      3.2
user:        Florent Xicluna <florent.xicluna at gmail.com>
date:        Sun Oct 30 20:22:25 2011 +0100
summary:
  Issue #13293: Better error message when trying to marshal bytes using xmlrpc.client.

files:
  Lib/xmlrpc/client.py |  10 +---------
  Misc/NEWS            |   3 +++
  2 files changed, 4 insertions(+), 9 deletions(-)


diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -503,9 +503,7 @@
             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 @@
         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))
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -63,6 +63,9 @@
 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.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list